Zelda Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2023-06-06 22:07:05
Exec Total Coverage
Lines: 8584 12292 69.8%
Functions: 73 106 68.9%
Branches: 5450 10038 54.3%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // qst.cc
6 //
7 // Code for loading '.qst' files in ZC and ZQuest.
8 //
9 //--------------------------------------------------------
10
11 #include "allegro/file.h"
12 #include "base/util.h"
13 #include "base/zapp.h"
14 #include <filesystem>
15 #include <stdio.h>
16 #include <string.h>
17
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 #include <string>
18 #include <map>
19 #include <vector>
20 #include <assert.h>
21 #include <fmt/format.h>
22
23
24 #include "metadata/sigs/devsig.h.sig"
25 #include "metadata/sigs/compilersig.h.sig"
26 #include "metadata/versionsig.h"
27 #include "base/zc_alleg.h"
28 #include "base/zdefs.h"
29 #include "base/colors.h"
30 #include "tiles.h"
31 #include "base/zsys.h"
32 #include "qst.h"
33 #include "defdata.h"
34 #include "subscr.h"
35 #include "font.h"
36 #include "zc/zc_custom.h"
37 #include "sfx.h"
38 #include "md5.h"
39 #include "zc/ffscript.h"
40 #include "particles.h"
41 #include "dialog/alert.h"
42
43 #ifdef __EMSCRIPTEN__
44 #include "base/emscripten_utils.h"
45 #endif
46
47 //FFScript FFCore;
48 extern FFScript FFCore;
49 extern ZModule zcm;
50 extern zcmodule moduledata;
51 extern uint8_t __isZQuest;
52 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
53 extern particle_list particles;
54 extern void setZScriptVersion(int32_t s_version);
55 //FFSCript FFEngine;
56
57 int32_t temp_ffscript_version = 0;
58 static bool read_ext_zinfo = false, read_zinfo = false;
59 static bool loadquest_report = false;
60 static char const* loading_qst_name = NULL;
61 static byte loading_qst_num = 0;
62
63 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0};
64 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
65
66 #ifdef _MSC_VER
67 #define strncasecmp _strnicmp
68 #endif
69
70 #ifndef _AL_MALLOC
71 #define _AL_MALLOC(a) _al_malloc(a)
72 #define _AL_FREE(a) _al_free(a)
73 #endif
74
75 using std::string;
76 using std::pair;
77
78 // extern bool debug;
79 extern int32_t hero_animation_speed; //lower is faster animation
80 extern std::vector<mapscr> TheMaps;
81 extern zcmap *ZCMaps;
82 extern MsgStr *MsgStrings;
83 extern DoorComboSet *DoorComboSets;
84 extern dmap *DMaps;
85 extern newcombo *combobuf;
86 extern byte *colordata;
87 //extern byte *tilebuf;
88 extern tiledata *newtilebuf;
89 extern byte *trashbuf;
90 extern itemdata *itemsbuf;
91 extern wpndata *wpnsbuf;
92 extern comboclass *combo_class_buf;
93 extern guydata *guysbuf;
94 extern ZCHEATS zcheats;
95 extern zinitdata zinit;
96 extern char palnames[MAXLEVELS][17];
97 extern int32_t memrequested;
98 extern char *byte_conversion(int32_t number, int32_t format);
99 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
100 33 string zScript;
101
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
33 std::map<int32_t, script_slot_data > ffcmap;
102 33 std::map<int32_t, script_slot_data > globalmap;
103 33 std::map<int32_t, script_slot_data > genericmap;
104 33 std::map<int32_t, script_slot_data > itemmap;
105 33 std::map<int32_t, script_slot_data > npcmap;
106 33 std::map<int32_t, script_slot_data > ewpnmap;
107 33 std::map<int32_t, script_slot_data > lwpnmap;
108 33 std::map<int32_t, script_slot_data > playermap;
109 33 std::map<int32_t, script_slot_data > dmapmap;
110 33 std::map<int32_t, script_slot_data > screenmap;
111 33 std::map<int32_t, script_slot_data > itemspritemap;
112 33 std::map<int32_t, script_slot_data > comboscriptmap;
113 void free_newtilebuf();
114 bool combosread=false;
115 bool mapsread=false;
116 bool fixffcs=false;
117 bool fixpolsvoice=false;
118
119
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
120
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
121
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
122
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
123
124 char qstdat_string[2048] = { 0 };
125
126 static zinfo* load_tmp_zi = NULL;
127
128 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
129 const byte clavio[9]={97,109,111,110,103,117,115,0};
130
131 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
132 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
133
134 extern combo_alias combo_aliases[MAXCOMBOALIASES];
135 extern combo_pool combo_pools[MAXCOMBOPOOLS];
136 const char *qst_error[] =
137 {
138 "OK","File not found","Invalid quest file",
139 "Version not supported","Obsolete version",
140 "Missing new data" , /* but let it pass in ZQuest */
141 "Internal error occurred", "Invalid password",
142 "Doesn't match saved game", "Save file is for older version of quest; please start new save",
143 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
144 };
145
146 //for legacy quests -DD
147 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
148 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
149 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
150 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
151 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
152 };
153
154 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
155
156
157 void delete_combo_aliases()
158 {
159 for(int32_t j(0); j<256; j++)
160 {
161 if(combo_aliases[j].combos != NULL)
162 {
163 delete[] combo_aliases[j].combos;
164 combo_aliases[j].combos=NULL;
165 }
166
167 if(combo_aliases[j].csets != NULL)
168 {
169 delete[] combo_aliases[j].csets;
170 combo_aliases[j].csets=NULL;
171 }
172 }
173
174 }
175
176 char *byte_conversion(int32_t number, int32_t format)
177 {
178 static char num_str[40];
179
180 if(format==-1) //auto
181 {
182 format=1; //bytes
183
184 if(number>1024)
185 {
186 format=2; //kilobytes
187 }
188
189 if(number>1024*1024)
190 {
191 format=3; //megabytes
192 }
193
194 if(number>1024*1024*1024)
195 {
196 format=4; //gigabytes (dude, what are you doing?)
197 }
198 }
199
200 switch(format)
201 {
202 case 1: //bytes
203 sprintf(num_str,"%db",number);
204 break;
205
206 case 2: //kilobytes
207 sprintf(num_str,"%.2fk",float(number)/1024);
208 break;
209
210 case 3: //megabytes
211 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
212 break;
213
214 case 4: //gigabytes
215 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
216 break;
217
218 default:
219 abort();
220 break;
221 }
222
223 return num_str;
224 }
225
226 462 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
227 {
228 static char num_str1[40];
229 static char num_str2[40];
230 static char num_str[80];
231
232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 462 times.
462 if(format1==-1) //auto
233 {
234 462 format1=1; //bytes
235
236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 462 times.
462 if(number1>1024)
237 {
238 462 format1=2; //kilobytes
239 462 }
240
241
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 132 times.
462 if(number1>1024*1024)
242 {
243 132 format1=3; //megabytes
244 132 }
245
246
1/2
✓ Branch 0 taken 462 times.
✗ Branch 1 not taken.
462 if(number1>1024*1024*1024)
247 {
248 format1=4; //gigabytes (dude, what are you doing?)
249 }
250 462 }
251
252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 462 times.
462 if(format2==-1) //auto
253 {
254 462 format2=1; //bytes
255
256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 462 times.
462 if(number2>1024)
257 {
258 462 format2=2; //kilobytes
259 462 }
260
261
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 429 times.
462 if(number2>1024*1024)
262 {
263 429 format2=3; //megabytes
264 429 }
265
266
1/2
✓ Branch 0 taken 462 times.
✗ Branch 1 not taken.
462 if(number2>1024*1024*1024)
267 {
268 format2=4; //gigabytes (dude, what are you doing?)
269 }
270 462 }
271
272
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 330 times.
✓ Branch 3 taken 132 times.
✗ Branch 4 not taken.
462 switch(format1)
273 {
274 case 1: //bytes
275 sprintf(num_str1,"%db",number1);
276 break;
277
278 case 2: //kilobytes
279 330 sprintf(num_str1,"%.2fk",float(number1)/1024);
280 330 break;
281
282 case 3: //megabytes
283 132 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
284 132 break;
285
286 case 4: //gigabytes
287 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
288 break;
289
290 default:
291 abort();
292 break;
293 }
294
295
2/5
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 429 times.
✗ Branch 4 not taken.
462 switch(format2)
296 {
297 case 1: //bytes
298 sprintf(num_str2,"%db",number2);
299 break;
300
301 case 2: //kilobytes
302 33 sprintf(num_str2,"%.2fk",float(number2)/1024);
303 33 break;
304
305 case 3: //megabytes
306 429 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
307 429 break;
308
309 case 4: //gigabytes
310 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
311 break;
312
313 default:
314 abort();
315 break;
316 }
317
318 462 sprintf(num_str, "%s/%s", num_str1, num_str2);
319 462 return num_str;
320 }
321
322 char *ordinal(int32_t num)
323 {
324 static const char *ending[4] = {"st","nd","rd","th"};
325 static char ord_str[8];
326
327 char *end;
328 int32_t t=(num%100)/10;
329 int32_t n=num%10;
330
331 if(n>=1 && n<4 && t!=1)
332 end = (char *)ending[n-1];
333 else
334 end = (char *)ending[3];
335
336 sprintf(ord_str,"%d%s",num%10000,end);
337 return ord_str;
338 }
339
340 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
341 {
342 int32_t ret;
343 *version=0;
344 *build=0;
345 byte temp_map_count=map_count;
346 byte temp_midi_flags[MIDIFLAGS_SIZE];
347 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
348
349 zquestheader tempheader;
350
351 if(!f)
352 {
353 return qe_invalid;
354 }
355
356 ret=readheader(f, &tempheader, true);
357
358 if(ret)
359 {
360 return ret;
361 }
362
363 map_count=temp_map_count;
364 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
365 *version=tempheader.zelda_version;
366 *build=tempheader.build;
367 return 0;
368 }
369
370
371 bool find_section(PACKFILE *f, int32_t section_id_requested)
372 {
373
374 if(!f)
375 {
376 return false;
377 }
378
379 int32_t section_id_read;
380 bool catchup=false;
381 word dummy;
382 byte tempbyte;
383 char tempbuf[65536];
384
385
386 switch(section_id_requested)
387 {
388 case ID_RULES:
389 case ID_STRINGS:
390 case ID_MISC:
391 case ID_TILES:
392 case ID_COMBOS:
393 case ID_CSETS:
394 case ID_MAPS:
395 case ID_DMAPS:
396 case ID_DOORS:
397 case ID_ITEMS:
398 case ID_WEAPONS:
399 case ID_COLORS:
400 case ID_ICONS:
401 case ID_INITDATA:
402 case ID_GUYS:
403 case ID_MIDIS:
404 case ID_CHEATS:
405 break;
406
407 default:
408 al_trace("Bad section requested!\n");
409 return false;
410 break;
411 }
412
413 dword section_size;
414
415 //section id
416 if(!p_mgetl(&section_id_read,f,true))
417 {
418 return false;
419 }
420
421 while(!pack_feof(f))
422 {
423 switch(section_id_read)
424 {
425 case ID_RULES:
426 case ID_STRINGS:
427 case ID_MISC:
428 case ID_TILES:
429 case ID_COMBOS:
430 case ID_CSETS:
431 case ID_MAPS:
432 case ID_DMAPS:
433 case ID_DOORS:
434 case ID_ITEMS:
435 case ID_WEAPONS:
436 case ID_COLORS:
437 case ID_ICONS:
438 case ID_INITDATA:
439 case ID_GUYS:
440 case ID_MIDIS:
441 case ID_CHEATS:
442 catchup=false;
443 break;
444
445 default:
446 break;
447 }
448
449
450 while(catchup)
451 {
452 //section id
453 section_id_read=(section_id_read<<8);
454
455 if(!p_getc(&tempbyte,f,true))
456 {
457 return false;
458 }
459
460 section_id_read+=tempbyte;
461 }
462
463 if(section_id_read==section_id_requested)
464 {
465 return true;
466 }
467 else
468 {
469 //section version info
470 if(!p_igetw(&dummy,f,true))
471 {
472 return false;
473 }
474
475 if(!p_igetw(&dummy,f,true))
476 {
477 return false;
478 }
479
480 //section size
481 if(!p_igetl(&section_size,f,true))
482 {
483 return false;
484 }
485
486 //pack_fseek(f, section_size);
487 while(section_size>65535)
488 {
489 pfread(tempbuf,65535,f,true);
490 tempbuf[65535]=0;
491 section_size-=65535;
492 }
493
494 if(section_size>0)
495 {
496 pfread(tempbuf,section_size,f,true);
497 tempbuf[section_size]=0;
498 }
499 }
500
501 //section id
502 if(!p_mgetl(&section_id_read,f,true))
503 {
504 return false;
505 }
506 }
507
508 return false;
509 }
510
511
512
513
514
515 bool valid_zqt(PACKFILE *f)
516 {
517
518 //word tiles_used;
519 //word combos_used;
520 //open the file
521 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
522 if(!f)
523 return false;
524
525 //for now, everything else is valid
526 return true;
527
528 /*int16_t version;
529 byte build;
530
531 //read the version and make sure it worked
532 if(!p_igetw(&version,f,true))
533 {
534 goto error;
535 }
536
537 //read the build and make sure it worked
538 if(!p_getc(&build,f,true))
539 goto error;
540
541 //read the tile info and make sure it worked
542 if(!p_igetw(&tiles_used,f,true))
543 {
544 goto error;
545 }
546
547 for (int32_t i=0; i<tiles_used; i++)
548 {
549 if(!pfread(trashbuf,tilesize(tf4Bit),f,true))
550 {
551 goto error;
552 }
553 }
554
555 //read the combo info and make sure it worked
556 if(!p_igetw(&combos_used,f,true))
557 {
558 goto error;
559 }
560 for (int32_t i=0; i<combos_used; i++)
561 {
562 if(!pfread(trashbuf,sizeof(newcombo),f,true))
563 {
564 goto error;
565 }
566 }
567
568 //read the palette info and make sure it worked
569 for (int32_t i=0; i<48; i++)
570 {
571 if(!pfread(trashbuf,newpdTOTAL,f,true))
572 {
573 goto error;
574 }
575 }
576 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f,true))
577 {
578 goto error;
579 }
580 for (int32_t i=0; i<MAXLEVELS; i++)
581 {
582 if(!pfread(trashbuf,PALNAMESIZE,f,true))
583 {
584 goto error;
585 }
586 }
587
588 //read the sprite info and make sure it worked
589 for (int32_t i=0; i<MAXITEMS; i++)
590 {
591 if(!pfread(trashbuf,sizeof(itemdata),f,true))
592 {
593 goto error;
594 }
595 }
596
597 for (int32_t i=0; i<MAXWPNS; i++)
598 {
599 if(!pfread(trashbuf,sizeof(wpndata),f,true))
600 {
601 goto error;
602 }
603 }
604
605 //read the triforce pieces info and make sure it worked
606 for (int32_t i=0; i<8; ++i)
607 {
608 if(!p_getc(&trashbuf,f,true))
609 {
610 goto error;
611 }
612 }
613
614
615
616 //read the game icons info and make sure it worked
617 for (int32_t i=0; i<4; ++i)
618 {
619 if(!p_igetw(&trashbuf,f,true))
620 {
621 goto error;
622 }
623 }
624
625 //read the misc colors info and map styles info and make sure it worked
626 if(!pfread(trashbuf,sizeof(zcolors),f,true))
627 {
628 goto error;
629 }
630
631 //read the template screens and make sure it worked
632 byte num_maps;
633 if(!p_getc(&num_maps,f,true))
634 {
635 goto error;
636 }
637 for (int32_t i=0; i<TEMPLATES; i++)
638 {
639 if(!pfread(trashbuf,sizeof(mapscr),f,true))
640 {
641 goto error;
642 }
643 }
644 if (num_maps>1) //dungeon templates
645 {
646 for (int32_t i=0; i<TEMPLATES; i++)
647 {
648 if(!pfread(trashbuf,sizeof(mapscr),f,true))
649 {
650 goto error;
651 }
652 }
653 }
654
655 //yay! it worked! close the file and say everything was ok.
656 pack_fclose(f);
657 return true;
658
659 error:
660 pack_fclose(f);
661 return false;*/
662 }
663
664 bool valid_zqt(const char *filename)
665 {
666 PACKFILE *f=NULL;
667 bool isvalid;
668 int32_t error;
669 f=open_quest_file(&error, filename, false);
670
671 if(!f)
672 {
673 // setPackfilePassword(NULL);
674 return false;
675 }
676
677 isvalid=valid_zqt(f);
678
679 clear_quest_tmpfile();
680 pack_fclose(f);
681
682 // setPackfilePassword(NULL);
683 return isvalid;
684 }
685
686 33 static std::string tmp_file_name;
687 218 void clear_quest_tmpfile()
688 {
689
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 8 times.
218 if(tmp_file_name.size())
690 {
691
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(exists(tmp_file_name.c_str()))
692 8 delete_file(tmp_file_name.c_str());
693 8 tmp_file_name.clear();
694 8 }
695 218 }
696 /*
697 .qst file history
698
699 .qst files have always been compressed using allegro's packfiles.
700
701 At some point, an encoding layer was added. The two layers look like this:
702
703 1) The top layer is from us. See decode_file_007.
704 [0-24] Preamble "Zelda Classic Quest File"
705 [25-28] Initial decoding seed value.
706 [29-X] Allegro-encoded payload (AKA "packed" file)
707 [last 4] Checksum
708
709 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
710 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
711 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
712 The oldest quests skip the password part.
713
714 Simply, the job of this function is to peel away the top layer.
715
716 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
717 in opening and saving files. There is no version field, so they decryption key is
718 found via trial-by-error (very slow!)
719
720 There are other file types of interest:
721 - .zqt: quest template files, skips top-layer encryption pass
722 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
723 - .qu?: same as above. automated backup files
724 - .qb?: same as above. automated backup files
725 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
726
727 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
728 files are now "slh!.AG ZC Enhanced Quest File".
729 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
730 */
731 109 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
732 {
733
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if (show_progress)
734 {
735 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
736 }
737
738 #ifdef __EMSCRIPTEN__
739 if (em_is_lazy_file(filename))
740 {
741 em_fetch_file(filename);
742 }
743 #endif
744 109 clear_quest_tmpfile();
745 // Note: although this is primarily for loading .qst files, it can also handle all of the
746 // file types mentioned in the comment above. No need to be told if the file being loaded
747 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
748 109 bool top_layer_compressed = false;
749 109 bool compressed = false;
750 109 bool encrypted = false;
751
752 // Input files may or may not include a top layer, which may or may not be compressed.
753 // Additionally, the bottom layer may or may not be compressed, and may or may not be encoded
754 // with an allegro packfile password (longtan).
755 // We peek into this file to read the header - we'll either see the top layer's header (ENC_STR)
756 // or the bottom layer's header (QH_IDSTR or QH_NEWIDSTR).
757 // Newly saved .qst files enjoy a fast path here, where there is no top layer at all.
758
759 109 bool id_came_from_compressed_file = false;
760 109 const char* packfile_password = "";
761 char id[32];
762 109 id[0] = id[31] = '\0';
763 109 PACKFILE* pf = pack_fopen_password(filename, F_READ_PACKED, "");
764
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 11 times.
109 if (!pf)
765 11 pf = pack_fopen_password(filename, F_READ_PACKED, packfile_password = datapwd);
766
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 3 times.
109 if (pf)
767 {
768 106 id_came_from_compressed_file = true;
769
1/2
✓ Branch 0 taken 106 times.
✗ Branch 1 not taken.
106 if (!pack_fread(id, sizeof(id)-1, pf))
770 {
771 pack_fclose(pf);
772 Z_message("Unable to read header string\n");
773 return nullptr;
774 }
775 106 pack_fclose(pf);
776 106 }
777 else
778 {
779 3 FILE* f = fopen(filename, "rb");
780
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (!f)
781 {
782 *open_error=qe_notfound;
783 return nullptr;
784 }
785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!fread(id, sizeof(char), sizeof(id)-1, f))
786 {
787 fclose(f);
788 Z_message("Unable to read header string\n");
789 return nullptr;
790 }
791 3 fclose(f);
792 }
793
794
4/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 94 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 11 times.
109 if (strstr(id, QH_NEWIDSTR) || strstr(id, QH_IDSTR))
795 {
796 // The given file is already just the bottom layer - nothing more to do.
797 // There's no way to rewind a packfile, so just open it again.
798
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 if (id_came_from_compressed_file)
799 {
800 98 return pack_fopen_password(filename, F_READ_PACKED, packfile_password);
801 }
802 else
803 {
804 return pack_fopen_password(filename, F_READ, "");
805 }
806 }
807
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 8 times.
11 else if (strstr(id, ENC_STR))
808 {
809 3 top_layer_compressed = id_came_from_compressed_file;
810 3 compressed = true;
811 3 encrypted = true;
812 3 }
813
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 else if (id_came_from_compressed_file && strstr(id, "slh!\xff"))
814 {
815 // We must be reading the compressed contents of an allegro dataobject file. ex: `classic_qst.dat#NESQST_NEW_QST`.
816 // Let's extract the content and re-open as a separate file, so allegro will uncompress correctly.
817
818 char tmpfilename[L_tmpnam];
819 8 std::tmpnam(tmpfilename);
820 8 FILE* tf = fopen(tmpfilename, "wb");
821 8 PACKFILE* pf = pack_fopen_password(filename, F_READ_PACKED, packfile_password);
822
823 int c;
824
2/2
✓ Branch 0 taken 24345520 times.
✓ Branch 1 taken 8 times.
24345528 while ((c = pack_getc(pf)) != EOF)
825 {
826 24345520 fputc(c, tf);
827 }
828 8 fclose(tf);
829 8 pack_fclose(pf);
830
831 8 tmp_file_name = tmpfilename; //store so it can be cleaned up later
832
833 // not good: temp file storage leak. Callers don't know to delete temp files anymore.
834 // We should put qsu in the dat file, or use a separate .qst file for new qst.
835 8 return pack_fopen_password(tmpfilename, F_READ_PACKED, "");
836 }
837 else
838 {
839 // Unexpected, this is going to fail some header check later.
840 }
841
842 // Everything below here is legacy code - recently saved quest files will have
843 // returned by now.
844
845 char tmpfilename[L_tmpnam];
846 3 temp_name(tmpfilename);
847 char percent_done[30];
848 3 int32_t current_method=0;
849
850 PACKFILE *f;
851 3 const char *passwd= encrypted ? datapwd : "";
852
853 // oldquest flag is set when an unencrypted qst file is suspected.
854 3 bool oldquest = false;
855 int32_t ret;
856
857
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(strcmp(filename, moduledata.datafiles[qst_dat])!=0)
858 {
859 3 box_out(filename);
860 3 }
861 else
862 {
863 box_out("new quest"); // Or whatever
864 }
865 3 box_out("...");
866 3 box_eol();
867 3 box_eol();
868
869
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(encrypted)
870 {
871 3 box_out("Decrypting...");
872 3 box_save_x();
873 3 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
874
875
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(ret)
876 {
877 switch(ret)
878 {
879 case 1:
880 box_out("error.");
881 box_eol();
882 box_end(true);
883 *open_error=qe_notfound;
884 return NULL;
885
886 case 2:
887 box_out("error.");
888 box_eol();
889 box_end(true);
890 *open_error=qe_internal;
891 return NULL;
892 // be sure not to delete tmpfilename now...
893 }
894
895 if(ret==5) //old encryption?
896 {
897 current_method++;
898 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
899 box_out(percent_done);
900 box_load_x();
901 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
902 }
903
904 if(ret==5) //old encryption?
905 {
906 current_method++;
907 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
908 box_out(percent_done);
909 box_load_x();
910 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
911 }
912
913 if(ret==5) //old encryption?
914 {
915 current_method++;
916 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
917 box_out(percent_done);
918 box_load_x();
919 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
920 }
921
922 if(ret==5) //old encryption?
923 {
924 current_method++;
925 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
926 box_out(percent_done);
927 box_load_x();
928 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
929 }
930
931 if(ret)
932 {
933 oldquest = true;
934 passwd="";
935 }
936 }
937
938 3 box_out("okay.");
939 3 box_eol();
940 3 }
941 else
942 {
943 oldquest = true;
944 }
945
946 3 box_out("Opening...");
947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
948
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!f)
949 {
950 if((compressed==1)&&(errno==EDOM))
951 {
952 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
953 }
954
955 if(!f)
956 {
957 if(!oldquest)
958 {
959 delete_file(tmpfilename);
960 }
961 box_out("error.");
962 box_eol();
963 box_end(true);
964 *open_error=qe_invalid;
965 return NULL;
966 }
967 }
968
969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!oldquest)
970 {
971 3 delete_file(tmpfilename);
972 3 }
973
974 3 box_out("okay.");
975 3 box_eol();
976
977 3 return f;
978 109 }
979
980 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
981 {
982 char *filename;
983 PACKFILE *f=NULL;
984 int32_t open_error=0;
985
986 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
987 strcat(qstdat_string,"#NESQST_NEW_QST");
988 if(Header->templatepath[0]==0)
989 {
990 filename=(char *)malloc(2048);
991 strcpy(filename, qstdat_string);
992 }
993 else
994 {
995 // TODO: should be safe to remove this, no one seems to use custom quest templates.
996 filename=Header->templatepath;
997 }
998
999 f=open_quest_file(&open_error, filename, false);
1000
1001 if(Header->templatepath[0]==0)
1002 {
1003 free(filename);
1004 }
1005
1006 if(!f)
1007 {
1008 return NULL;
1009 }
1010
1011 if(validate)
1012 {
1013 if(!valid_zqt(f))
1014 {
1015 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
1016 pack_fclose(f);
1017 clear_quest_tmpfile();
1018 return NULL;
1019 }
1020 }
1021
1022 return f;
1023 }
1024
1025 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
1026 {
1027 // We absolutely do not support loading from a template file to initialize data outside the editor.
1028 // TODO: move this code into zq/
1029 if (get_app_id() != App::zquest) return false;
1030
1031 combosread=false;
1032 mapsread=false;
1033 fixffcs=false;
1034
1035 switch(section_id)
1036 {
1037 case ID_RULES:
1038 case ID_STRINGS:
1039 case ID_MISC:
1040 case ID_TILES:
1041 case ID_COMBOS:
1042 case ID_CSETS:
1043 case ID_MAPS:
1044 case ID_DMAPS:
1045 case ID_DOORS:
1046 case ID_ITEMS:
1047 case ID_WEAPONS:
1048 case ID_COLORS:
1049 case ID_ICONS:
1050 case ID_INITDATA:
1051 case ID_GUYS:
1052 case ID_MIDIS:
1053 case ID_CHEATS:
1054 case ID_ITEMDROPSETS:
1055 case ID_FAVORITES:
1056 break;
1057
1058 default:
1059 return false;
1060 break;
1061 }
1062
1063 int32_t ret;
1064 word version, build;
1065 PACKFILE *f=NULL;
1066
1067 char deletefilename[1024];
1068 deletefilename[0]=0;
1069
1070 //why is this here?
1071 /*
1072 if(colordata==NULL)
1073 return false;
1074 */
1075
1076 //setPackfilePassword(datapwd);
1077 f=open_quest_template(Header, deletefilename, validate);
1078
1079 if(!f) //no file, nothing to delete
1080 {
1081 // setPackfilePassword(NULL);
1082 return false;
1083 }
1084
1085 ret=get_version_and_build(f, &version, &build);
1086
1087 if(ret||(version==0))
1088 {
1089 pack_fclose(f);
1090 clear_quest_tmpfile();
1091
1092 if(deletefilename[0])
1093 {
1094 delete_file(deletefilename);
1095 }
1096
1097 // setPackfilePassword(NULL);
1098 return false;
1099 }
1100
1101 if(!find_section(f, section_id))
1102 {
1103 al_trace("Can't find section!\n");
1104 pack_fclose(f);
1105 clear_quest_tmpfile();
1106
1107 if(deletefilename[0])
1108 {
1109 delete_file(deletefilename);
1110 }
1111
1112 //setPackfilePassword(NULL);
1113 return false;
1114 }
1115
1116 switch(section_id)
1117 {
1118 case ID_RULES:
1119 //rules
1120 ret=readrules(f, Header, true);
1121 break;
1122
1123 case ID_STRINGS:
1124 //strings
1125 ret=readstrings(f, Header, true);
1126 break;
1127
1128 case ID_MISC:
1129 //misc data
1130 ret=readmisc(f, Header, Misc, true);
1131 break;
1132
1133 case ID_TILES:
1134 //tiles
1135 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true, true);
1136 break;
1137
1138 case ID_COMBOS:
1139 //combos
1140 clear_combos();
1141 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS, true);
1142 combosread=true;
1143 break;
1144
1145 case ID_COMBOALIASES:
1146 //combos
1147 ret=readcomboaliases(f, Header, version, build, true);
1148 break;
1149
1150 case ID_CSETS:
1151 //color data
1152 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL, true);
1153 break;
1154
1155 case ID_MAPS:
1156 //maps
1157 ret=readmaps(f, Header, true);
1158 mapsread=true;
1159 break;
1160
1161 case ID_DMAPS:
1162 //dmaps
1163 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS, true);
1164 break;
1165
1166 case ID_DOORS:
1167 //door combo sets
1168 ret=readdoorcombosets(f, Header, true);
1169 break;
1170
1171 case ID_ITEMS:
1172 //items
1173 ret=readitems(f, version, build, true);
1174 break;
1175
1176 case ID_WEAPONS:
1177 //weapons
1178 ret=readweapons(f, Header, true);
1179 break;
1180
1181 case ID_COLORS:
1182 //misc. colors
1183 ret=readmisccolors(f, Header, Misc, true);
1184 break;
1185
1186 case ID_ICONS:
1187 //game icons
1188 ret=readgameicons(f, Header, Misc, true);
1189 break;
1190
1191 case ID_INITDATA:
1192 //initialization data
1193 ret=readinitdata(f, Header, true);
1194 break;
1195
1196 case ID_GUYS:
1197 //guys
1198 ret=readguys(f, Header, true);
1199 break;
1200
1201 case ID_MIDIS:
1202 //midis
1203 ret=readtunes(f, Header, tunes, true);
1204 break;
1205
1206 case ID_CHEATS:
1207 //cheat codes
1208 ret=readcheatcodes(f, Header, true);
1209 break;
1210
1211 case ID_ITEMDROPSETS:
1212 //item drop sets
1213 // Why is this one commented out?
1214 //ret=readitemdropsets(f, (int32_t)version, (word)build, true);
1215 break;
1216
1217 case ID_FAVORITES:
1218 // favorite combos and aliases
1219 ret=readfavorites(f, version, build, true);
1220 break;
1221
1222 default:
1223 ret=-1;
1224 break;
1225 }
1226
1227 pack_fclose(f);
1228 clear_quest_tmpfile();
1229
1230 if(deletefilename[0])
1231 {
1232 delete_file(deletefilename);
1233 }
1234
1235 //setPackfilePassword(NULL);
1236 if(!ret)
1237 {
1238 return true;
1239 }
1240
1241 return false;
1242 }
1243
1244 bool init_tiles(bool validate, zquestheader *Header)
1245 {
1246 return init_section(Header, ID_TILES, NULL, NULL, validate);
1247 }
1248
1249 bool init_combos(bool validate, zquestheader *Header)
1250 {
1251 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1252 }
1253
1254 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1255 {
1256 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1257 }
1258
1259 109 void init_spritelists()
1260 {
1261
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 25 times.
109 if(FFCore.quest_format[vZelda] < 0x255)
1262 {
1263 84 guys.setMax(255);
1264 84 items.setMax(255);
1265 84 Ewpns.setMax(255);
1266 84 Lwpns.setMax(255);
1267 84 Sitems.setMax(255);
1268 84 chainlinks.setMax(255);
1269 84 decorations.setMax(255);
1270 84 particles.setMax(255);
1271 84 }
1272 else
1273 {
1274 25 guys.setMax(255);
1275 25 items.setMax(255);
1276 25 Ewpns.setMax(255);
1277 25 Lwpns.setMax(255);
1278 25 Sitems.setMax(255);
1279 25 chainlinks.setMax(255);
1280 25 decorations.setMax(255);
1281 25 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1282 }
1283 109 }
1284
1285 33 bool reset_items(bool validate, zquestheader *Header)
1286 {
1287 33 bool ret = true;
1288
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if (get_app_id() == App::zquest)
1289 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1290
1291
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 8448 times.
8481 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1292
1293 33 return ret;
1294 }
1295
1296 bool reset_guys()
1297 {
1298 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1299 init_guys(V_GUYS);
1300 return true;
1301 }
1302
1303 bool reset_wpns(bool validate, zquestheader *Header)
1304 {
1305 bool ret = true;
1306 if (get_app_id() == App::zquest)
1307 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1308
1309 for(int32_t i=0; i<WPNCNT; i++)
1310 reset_weaponname(i);
1311
1312 return ret;
1313 }
1314
1315 bool reset_mapstyles(bool validate, miscQdata *Misc)
1316 {
1317 Misc->colors.blueframe_tile = 20044;
1318 Misc->colors.blueframe_cset = 0;
1319 Misc->colors.triforce_tile = 23461;
1320 Misc->colors.triforce_cset = 1;
1321 Misc->colors.triframe_tile = 18752;
1322 Misc->colors.triframe_cset = 1;
1323 Misc->colors.overworld_map_tile = 16990;
1324 Misc->colors.overworld_map_cset = 2;
1325 Misc->colors.HCpieces_tile = 21160;
1326 Misc->colors.HCpieces_cset = 8;
1327 Misc->colors.dungeon_map_tile = 19651;
1328 Misc->colors.dungeon_map_cset = 8;
1329 return true;
1330 }
1331
1332 33 int32_t get_qst_buffers()
1333 {
1334 33 memrequested+=(sizeof(mapscr)*MAPSCRS);
1335 33 Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
1336 33 TheMaps.resize(MAPSCRS);
1337
1338
2/2
✓ Branch 0 taken 4488 times.
✓ Branch 1 taken 33 times.
4521 for(int32_t i(0); i<MAPSCRS; i++)
1339 4488 TheMaps[i].zero_memory();
1340
1341 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1342 33 Z_message("OK\n"); // Allocating map buffer...
1343
1344 33 memrequested+=(sizeof(zcmap)*MAXMAPS2);
1345 33 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(zcmap)*MAXMAPS2,memrequested,-1,-1));
1346
1347
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((ZCMaps=(zcmap*)malloc(sizeof(zcmap)*MAXMAPS2))==NULL)
1348 return 0;
1349
1350 33 Z_message("OK\n");
1351
1352 // Allocating space for all 65535 strings uses up 10.62MB...
1353 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1354 // (Shoelace's "Hero of Dreams" uses 1415.)
1355 // So let's be a bit generous and allow 4096 initially.
1356 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1357 // I tested it and it worked without flaw on 6/6/11. - L.
1358 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1359 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1360 // See https://discord.com/channels/876899628556091432/992984989073416242
1361 33 msg_strings_size = 8192;
1362 33 memrequested+=(sizeof(MsgStr)*msg_strings_size);
1363 33 Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));
1364
1365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 MsgStrings = new MsgStr[msg_strings_size];
1366
1367 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1368
2/2
✓ Branch 0 taken 270336 times.
✓ Branch 1 taken 33 times.
270369 for(auto q = 0; q < msg_strings_size; ++q)
1369 {
1370 270336 MsgStrings[q].clear();
1371 270336 }
1372 33 Z_message("OK\n"); // Allocating string buffer...
1373
1374 33 memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
1375 33 Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));
1376
1377
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1378 return 0;
1379
1380 33 Z_message("OK\n"); // Allocating door combo buffer...
1381
1382 33 memrequested+=(sizeof(dmap)*MAXDMAPS);
1383 33 Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));
1384
1385
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((DMaps=(dmap*)malloc(sizeof(dmap)*MAXDMAPS))==NULL)
1386 return 0;
1387
1388 33 memset(DMaps, 0, sizeof(dmap)*MAXDMAPS);
1389 33 Z_message("OK\n"); // Allocating dmap buffer...
1390
1391 33 memrequested+=(sizeof(newcombo)*MAXCOMBOS);
1392 33 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
1393
1394
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((combobuf=(newcombo*)malloc(sizeof(newcombo)*MAXCOMBOS))==NULL)
1395 return 0;
1396
1397 33 memset(combobuf, 0, sizeof(newcombo)*MAXCOMBOS);
1398 33 Z_message("OK\n"); // Allocating combo buffer...
1399
1400 33 memrequested+=(psTOTAL255);
1401 33 Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));
1402
1403
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1404 return 0;
1405
1406 33 Z_message("OK\n"); // Allocating color data buffer...
1407
1408 33 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1409 33 Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));
1410
1411 33 free_newtilebuf();
1412
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1413 return 0;
1414
1415 33 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1416 //Z_message("Performed memset on tiles\n");
1417 33 clear_tiles(newtilebuf);
1418 //Z_message("Performed clear_tiles()\n");
1419 33 Z_message("OK\n"); // Allocating tile buffer...
1420
1421
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(is_zquest())
1422 {
1423 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1424 Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));
1425
1426 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1427 return 0;
1428
1429 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1430 clear_tiles(grabtilebuf);
1431 Z_message("OK\n"); // Allocating tile grab buffer...
1432 }
1433
1434 33 memrequested+=(100000);
1435 33 Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));
1436
1437
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((trashbuf=(byte*)malloc(100000))==NULL)
1438 return 0;
1439
1440 33 Z_message("OK\n"); // Allocating trash buffer...
1441
1442 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1443 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1444 // fixed by ensuring there's actually itemdata there.
1445 // If you change this, be sure to update del_qst_buffers, too.
1446
1447 33 memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
1448 33 Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));
1449
1450
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1451 return 0;
1452
1453 33 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1454 33 itemsbuf++;
1455 33 Z_message("OK\n"); // Allocating item buffer...
1456
1457 33 memrequested+=(sizeof(wpndata)*MAXWPNS);
1458 33 Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));
1459
1460
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1461 return 0;
1462
1463 33 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1464 33 Z_message("OK\n"); // Allocating weapon buffer...
1465
1466 33 memrequested+=(sizeof(guydata)*MAXGUYS);
1467 33 Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));
1468
1469
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1470 return 0;
1471
1472 33 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1473 33 Z_message("OK\n"); // Allocating guy buffer...
1474
1475 33 memrequested+=(sizeof(comboclass)*cMAX);
1476 33 Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));
1477
1478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1479 return 0;
1480
1481 33 Z_message("OK\n"); // Allocating combo class buffer...
1482
1483 33 return 1;
1484 33 }
1485
1486
1487 33 void free_newtilebuf()
1488 {
1489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(newtilebuf)
1490 {
1491 for(int32_t i=0; i<NEWMAXTILES; i++)
1492 if(newtilebuf[i].data)
1493 free(newtilebuf[i].data);
1494
1495 free(newtilebuf);
1496 newtilebuf = 0;
1497 }
1498 33 }
1499
1500 void free_grabtilebuf()
1501 {
1502 if(is_zquest())
1503 {
1504 if(grabtilebuf)
1505 {
1506 for(int32_t i=0; i<NEWMAXTILES; i++)
1507 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1508
1509 free(grabtilebuf);
1510 grabtilebuf = 0;
1511 }
1512 }
1513 }
1514
1515 void del_qst_buffers()
1516 {
1517 al_trace("Cleaning maps. \n");
1518
1519 if(ZCMaps) free(ZCMaps);
1520
1521 if(MsgStrings) delete[] MsgStrings;
1522
1523 if(DoorComboSets) free(DoorComboSets);
1524
1525 if(DMaps) free(DMaps);
1526
1527 if(combobuf) free(combobuf);
1528
1529 if(colordata) free(colordata);
1530
1531 al_trace("Cleaning tile buffers. \n");
1532 free_newtilebuf();
1533 free_grabtilebuf();
1534
1535 al_trace("Cleaning misc. \n");
1536
1537 if(trashbuf) free(trashbuf);
1538
1539 // See get_qst_buffers
1540 if(itemsbuf)
1541 {
1542 itemsbuf--;
1543 free(itemsbuf);
1544 }
1545
1546 if(wpnsbuf) free(wpnsbuf);
1547
1548 if(guysbuf) free(guysbuf);
1549
1550 if(combo_class_buf) free(combo_class_buf);
1551 }
1552
1553 4 bool init_palnames()
1554 {
1555 // if(palnames==NULL)
1556 // return false;
1557
1558
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t x=0; x<MAXLEVELS; x++)
1559 {
1560
4/4
✓ Branch 0 taken 2036 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
2048 switch(x)
1561 {
1562 case 0:
1563 4 sprintf(palnames[x],"Overworld");
1564 4 break;
1565
1566 case 10:
1567 4 sprintf(palnames[x],"Caves");
1568 4 break;
1569
1570 case 11:
1571 4 sprintf(palnames[x],"Passageways");
1572 4 break;
1573
1574 default:
1575 2036 sprintf(palnames[x],"%c",0);
1576 2036 break;
1577 }
1578 2048 }
1579
1580 4 return true;
1581 }
1582
1583 20993 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size, bool keepdata)
1584 {
1585 void *p;
1586
1587
1/2
✓ Branch 0 taken 20993 times.
✗ Branch 1 not taken.
20993 p = _AL_MALLOC(MAX(size, alloc_size));
1588
1589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20993 times.
20993 if(!p)
1590 {
1591 return NULL;
1592 }
1593
1594
1/2
✓ Branch 0 taken 20993 times.
✗ Branch 1 not taken.
20993 if(!pfread(p,size,f,keepdata))
1595 {
1596 _AL_FREE(p);
1597 return NULL;
1598 }
1599
1600
1/2
✓ Branch 0 taken 20993 times.
✗ Branch 1 not taken.
20993 if(pack_ferror(f))
1601 {
1602 _AL_FREE(p);
1603 return NULL;
1604 }
1605
1606 20993 return p;
1607 20993 }
1608
1609 /* read_midi:
1610 * Reads MIDI data from a datafile (this is not the same thing as the
1611 * standard midi file format).
1612 */
1613
1614 1839 static MIDI *read_midi(PACKFILE *f, bool)
1615 {
1616 MIDI *m;
1617 int32_t c;
1618 1839 int16_t divisions=0;
1619 1839 int32_t len=0;
1620
1621 1839 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1622
1623
1/2
✓ Branch 0 taken 1839 times.
✗ Branch 1 not taken.
1839 if(!m)
1624 {
1625 return NULL;
1626 }
1627
1628
2/2
✓ Branch 0 taken 58848 times.
✓ Branch 1 taken 1839 times.
60687 for(c=0; c<MIDI_TRACKS; c++)
1629 {
1630 58848 m->track[c].len = 0;
1631 58848 m->track[c].data = NULL;
1632 58848 }
1633
1634 1839 p_mgetw(&divisions,f,true);
1635 1839 m->divisions=divisions;
1636
1637
2/2
✓ Branch 0 taken 58848 times.
✓ Branch 1 taken 1839 times.
60687 for(c=0; c<MIDI_TRACKS; c++)
1638 {
1639 58848 p_mgetl(&len,f,true);
1640 58848 m->track[c].len=len;
1641
1642
2/2
✓ Branch 0 taken 37855 times.
✓ Branch 1 taken 20993 times.
58848 if(m->track[c].len > 0)
1643 {
1644 20993 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0, true);
1645
1646
1/2
✓ Branch 0 taken 20993 times.
✗ Branch 1 not taken.
20993 if(!m->track[c].data)
1647 {
1648 destroy_midi(m);
1649 return NULL;
1650 }
1651 20993 }
1652 58848 }
1653
1654 LOCK_DATA(m, sizeof(MIDI));
1655
1656
2/2
✓ Branch 0 taken 58848 times.
✓ Branch 1 taken 1839 times.
60687 for(c=0; c<MIDI_TRACKS; c++)
1657 {
1658
2/2
✓ Branch 0 taken 20993 times.
✓ Branch 1 taken 37855 times.
58848 if(m->track[c].data)
1659 {
1660 LOCK_DATA(m->track[c].data, m->track[c].len);
1661 20993 }
1662 58848 }
1663
1664 1839 return m;
1665 1839 }
1666
1667 void clear_combo(int32_t i)
1668 {
1669 combobuf[i].clear();
1670 }
1671
1672 void clear_combos()
1673 {
1674 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1675 clear_combo(tmpcounter);
1676 }
1677
1678 void pack_combos()
1679 {
1680 int32_t di = 0;
1681
1682 for(int32_t si=0; si<1024; si+=2)
1683 combobuf[di++] = combobuf[si];
1684
1685 for(; di<1024; di++)
1686 clear_combo(di);
1687 }
1688
1689 109 void reset_tunes(zctune *tune)
1690 {
1691
2/2
✓ Branch 0 taken 27468 times.
✓ Branch 1 taken 109 times.
27577 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1692 {
1693 27468 tune[i].reset();
1694 27468 }
1695 109 }
1696
1697
1698 /*void reset_midi(zcmidi_ *m)
1699 {
1700 m->title[0]=0;
1701 m->loop=1;
1702 m->volume=144;
1703 m->start=0;
1704 m->loop_start=-1;
1705 m->loop_end=-1;
1706 if(m->midi)
1707 {
1708 destroy_midi(m->midi);
1709 }
1710 m->midi=NULL;
1711 }
1712
1713
1714 void reset_midis(zcmidi_ *m)
1715 {
1716 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1717 {
1718 reset_midi(m+i);
1719 }
1720 }
1721 */
1722
1723 void reset_scr(int32_t scr)
1724 {
1725 /*
1726 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1727 for(unsigned i=0; i<sizeof(mapscr); i++)
1728 *(di++) = 0;
1729 TheMaps[scr].valid=mVERSION;
1730 */
1731
1732 TheMaps[scr].zero_memory();
1733 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1734
1735 for(int32_t i=0; i<6; i++)
1736 {
1737 //these will be uncommented later
1738 //TheMaps[scr].layerxsize[i]=16;
1739 //TheMaps[scr].layerysize[i]=11;
1740 TheMaps[scr].layeropacity[i]=255;
1741 }
1742
1743 TheMaps[scr].valid=mVERSION;
1744
1745 }
1746
1747 /* For reference:
1748
1749 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1750 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1751 */
1752
1753 3582 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1754 {
1755
2/2
✓ Branch 0 taken 16494 times.
✓ Branch 1 taken 1614 times.
18108 for(int32_t i=0; i<9; i++)
1756 {
1757
2/2
✓ Branch 0 taken 89124 times.
✓ Branch 1 taken 14526 times.
103650 for(int32_t j=0; j<6; j++)
1758 {
1759
2/2
✓ Branch 0 taken 29052 times.
✓ Branch 1 taken 60072 times.
89124 if(j<4)
1760 {
1761
2/2
✓ Branch 0 taken 58104 times.
✓ Branch 1 taken 1968 times.
60072 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1762 {
1763 1968 return false;
1764 }
1765
1766
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1767 {
1768 return false;
1769 }
1770
1771
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1772 {
1773 return false;
1774 }
1775
1776
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1777 {
1778 return false;
1779 }
1780 58104 }
1781
1782
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1783 {
1784 return false;
1785 }
1786
1787
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1788 {
1789 return false;
1790 }
1791
1792
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1793 {
1794 return false;
1795 }
1796
1797
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1798 {
1799 return false;
1800 }
1801 87156 }
1802
1803
2/2
✓ Branch 0 taken 11298 times.
✓ Branch 1 taken 3228 times.
14526 if(i<2)
1804 {
1805
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.flags[i]!=b.flags[i])
1806 {
1807 return false;
1808 }
1809
1810
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1811 {
1812 return false;
1813 }
1814
1815
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1816 {
1817 return false;
1818 }
1819
1820
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1821 {
1822 return false;
1823 }
1824
1825
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1826 {
1827 return false;
1828 }
1829 3228 }
1830
1831
2/2
✓ Branch 0 taken 9684 times.
✓ Branch 1 taken 4842 times.
14526 if(i<3)
1832 {
1833
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1834 {
1835 return false;
1836 }
1837
1838
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1839 {
1840 return false;
1841 }
1842
1843
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1844 {
1845 return false;
1846 }
1847
1848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4842 times.
4842 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1849 {
1850 return false;
1851 }
1852 4842 }
1853
1854
1/2
✓ Branch 0 taken 14526 times.
✗ Branch 1 not taken.
14526 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1855 {
1856 return false;
1857 }
1858
1859
1/2
✓ Branch 0 taken 14526 times.
✗ Branch 1 not taken.
14526 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1860 {
1861 return false;
1862 }
1863 14526 }
1864
1865 1614 return true;
1866 3582 }
1867
1868 int32_t doortranslations_u[9][4]=
1869 {
1870 {37,38,53,54},
1871 {37,38,39,40},
1872 {37,38,55,56},
1873 {37,38,39,40},
1874 {37,38,53,54},
1875 {37,38,53,54},
1876 {37,38,53,54},
1877 {7,8,23,24},
1878 {7,8,41,42}
1879 };
1880
1881 int32_t doortranslations_d[9][4]=
1882 {
1883 {117,118,133,134},
1884 {135,136,133,134},
1885 {119,120,133,134},
1886 {135,136,133,134},
1887 {117,118,133,134},
1888 {117,118,133,134},
1889 {117,118,133,134},
1890 {151,152,167,168},
1891 {137,138,167,168},
1892 };
1893
1894 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1895 int32_t doortranslations_l[9][6]=
1896 {
1897 {66,67,82,83,98,99},
1898 {66,68,82,84,98,100},
1899 {66,69,82,85,98,101},
1900 {66,68,82,84,98,100},
1901 {66,67,82,83,98,99},
1902 {66,67,82,83,98,99},
1903 {66,67,82,83,98,99},
1904 {64,65,80,81,96,97},
1905 {64,65,80,114,96,97},
1906 };
1907
1908 int32_t doortranslations_r[9][6]=
1909 {
1910
1911 {76,77,92,93,108,109},
1912 {75,77,91,93,107,109},
1913 {74,77,90,93,106,109},
1914 {75,77,91,93,107,109},
1915 {76,77,92,93,108,109},
1916 {76,77,92,93,108,109},
1917 {76,77,92,93,108,109},
1918 {78,79,94,95,110,111},
1919 {78,79,125,95,110,111},
1920 };
1921
1922 314668 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1923 {
1924 314668 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1925 }
1926
1927 308180 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1928 {
1929 //these are here to bypass compiler warnings about unused arguments
1930 308180 map=map;
1931 308180 scr=scr;
1932 308180 pos=pos;
1933
1934 //what does this function do?
1935 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1936 308180 return 2;
1937 }
1938
1939 7072 int32_t MakeDoors(int32_t map, int32_t scr)
1940 {
1941
2/2
✓ Branch 0 taken 5450 times.
✓ Branch 1 taken 1622 times.
7072 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1942 {
1943 5450 return 0;
1944 }
1945
1946 DoorComboSet tempdcs;
1947 1622 memset(&tempdcs, 0, sizeof(DoorComboSet));
1948
1949 //up
1950
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1951 {
1952
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1953 {
1954 58392 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1955 58392 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1956 58392 }
1957 14598 }
1958
1959 1622 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1960 1622 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1961 1622 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1962 1622 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1963 1622 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1964 1622 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1965
1966 //down
1967
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1968 {
1969
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1970 {
1971 58392 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1972 58392 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1973 58392 }
1974 14598 }
1975
1976 1622 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1977
1978 1622 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1979 1622 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1980 1622 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1981 1622 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1982 1622 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1983
1984 //left
1985 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1986
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1987 {
1988
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
1989 {
1990 87588 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1991 87588 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1992 87588 }
1993 14598 }
1994
1995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
1996 {
1997 if((j!=2)&&(j!=3))
1998 {
1999 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
2000 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
2001 }
2002 }
2003
2004 1622 tempdcs.bombdoorcombo_l[0]=0;
2005 1622 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
2006 1622 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
2007 1622 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
2008 1622 tempdcs.bombdoorcombo_l[2]=0;
2009 1622 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
2010 1622 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
2011 1622 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
2012
2013 //right
2014
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
2015 {
2016
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
2017 {
2018 87588 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
2019 87588 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
2020 87588 }
2021 14598 }
2022
2023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
2024 {
2025 if((j!=2)&&(j!=3))
2026 {
2027 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
2028 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
2029 }
2030 }
2031
2032 1622 tempdcs.bombdoorcombo_r[0]=0;
2033 1622 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
2034 1622 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
2035 1622 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
2036 1622 tempdcs.bombdoorcombo_r[2]=0;
2037 1622 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
2038 1622 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
2039 1622 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
2040
2041 int32_t k;
2042
2043
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3582 times.
3590 for(k=0; k<door_combo_set_count; k++)
2044 {
2045
2/2
✓ Branch 0 taken 1614 times.
✓ Branch 1 taken 1968 times.
3582 if(DoorComboSets[k]==tempdcs)
2046 {
2047 1614 break;
2048 }
2049 1968 }
2050
2051
2/2
✓ Branch 0 taken 1614 times.
✓ Branch 1 taken 8 times.
1622 if(k==door_combo_set_count)
2052 {
2053 8 DoorComboSets[k]=tempdcs;
2054 8 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
2055 8 ++door_combo_set_count;
2056 8 }
2057
2058 1622 return k;
2059 /*
2060 doorcombo_u[9][4];
2061 doorcset_u[9][4];
2062 doorcombo_d[9][4];
2063 doorcset_d[9][4];
2064 doorcombo_l[9][6];
2065 doorcset_l[9][6];
2066 doorcombo_r[9][6];
2067 doorcset_r[9][6];
2068 bombdoorcombo_u[2];
2069 bombdoorcset_u[2];
2070 bombdoorcombo_d[2];
2071 bombdoorcset_d[2];
2072 bombdoorcombo_l[3];
2073 bombdoorcset_l[3];
2074 bombdoorcombo_r[3];
2075 bombdoorcset_r[3];
2076 walkthroughcombo[4];
2077 walkthroughcset[4];
2078 */
2079 7072 }
2080
2081 905216 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
2082 {
2083 905216 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
2084 }
2085
2086 905216 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
2087 {
2088
2089 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
2090 }
2091
2092 905216 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
2093 {
2094 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
2095 }
2096
2097
2098 9 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
2099 {
2100 char temp_pwd[30];
2101 9 memset(temp_pwd,0,30);
2102
2103
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(pwdkey!=0)
2104 {
2105 9 memcpy(temp_pwd,encrypted_pwd,30);
2106 9 temp_pwd[29]=0;
2107
2108
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 9 times.
279 for(int32_t i=0; i<30; i++)
2109 {
2110 270 temp_pwd[i] -= pwdkey;
2111 270 int32_t t=pwdkey>>15;
2112 270 pwdkey = (pwdkey<<1)+t;
2113 270 }
2114 9 }
2115
2116 9 memcpy(pwd,temp_pwd,30);
2117 9 }
2118
2119
2120 85 bool devpwd()
2121 {
2122 #ifdef _DEBUG
2123 return true;
2124 #endif
2125 85 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio);
2126 }
2127 bool check_questpwd(zquestheader *Header, char *pwd)
2128 {
2129 #if DEVLEVEL > 3
2130 return true;
2131 #endif
2132
2133 if (devpwd()) return true;
2134 if ( (!strcmp(pwd, (char*)clavio)) ) return true;
2135 cvs_MD5Context ctx;
2136 uint8_t md5sum[16];
2137
2138 cvs_MD5Init(&ctx);
2139 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
2140 cvs_MD5Final(md5sum, &ctx);
2141
2142 return (memcmp(Header->pwd_hash,md5sum,16)==0);
2143 }
2144
2145 101 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2146 {
2147 101 zprint2("\n");
2148 101 zprint2("[ZQUEST CREATOR METADATA]\n");
2149
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(qst_num < moduledata.max_quest_files)
2150 zprint2("Loading module quest %d\n", qst_num+1);
2151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
101 if(path) zprint2("Loading '%s'\n", path);
2152
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 4 times.
101 if ( tempheader.new_version_id_main > 0 )
2153 {
2154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(tempheader.new_version_id_fourth > 0)
2155 zprint2("Last saved in ZQuest Version %d.%d.%d.%d ",
2156 tempheader.new_version_id_main,tempheader.new_version_id_second,
2157 tempheader.new_version_id_third,tempheader.new_version_id_fourth);
2158 97 else zprint2("Last saved in ZQuest Version: %d.%d.%d ",
2159 97 tempheader.new_version_id_main,tempheader.new_version_id_second,
2160 97 tempheader.new_version_id_third);
2161 97 }
2162 else
2163 {
2164
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 switch ( tempheader.zelda_version )
2165 {
2166 case 0x255:
2167 {
2168 zprint2("Last saved in ZQuest Version: 2.55.0, %s: %d", tempheader.getAlphaStr(), tempheader.getAlphaVer());
2169 break;
2170 }
2171 case 0x254:
2172 {
2173 zprint2("Last saved in ZQuest Version: 2.54.0, Alpha Build ID: %d", tempheader.build);
2174 break;
2175 }
2176 case 0x250:
2177 {
2178 switch(tempheader.build)
2179 {
2180 case 19:
2181 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 1"); break;
2182 case 20:
2183 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 2"); break;
2184 case 21:
2185 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 3"); break;
2186 case 22:
2187 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 4"); break;
2188 case 23:
2189 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 5"); break;
2190 case 24:
2191 zprint2("Last saved in ZQuest Version: 2.50.0, Release"); break;
2192 case 25:
2193 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 1"); break;
2194 case 26:
2195 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 2"); break;
2196 case 27:
2197 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 3"); break;
2198 case 28:
2199 zprint2("Last saved in ZQuest Version: 2.50.1, Release"); break;
2200 case 29:
2201 zprint2("Last saved in ZQuest Version: 2.50.2, Release"); break;
2202 case 30:
2203 zprint2("Last saved in ZQuest Version: 2.50.3, Gamma 1"); break;
2204 case 31:
2205 zprint2("Last saved in ZQuest Version: 2.53.0, Prior to Gamma 3"); break;
2206 case 32:
2207 zprint2("Last saved in ZQuest Version: 2.53.0"); break;
2208 case 33:
2209 zprint2("Last saved in ZQuest Version: 2.53.1"); break;
2210 default:
2211 zprint2("Last saved in ZQuest Version: %x, Build %d", tempheader.zelda_version,tempheader.build); break;
2212
2213 }
2214 break;
2215 }
2216
2217 case 0x211:
2218 {
2219 zprint2("Last saved in ZQuest Version: 2.11, Beta %d", tempheader.build); break;
2220 }
2221 case 0x210:
2222 {
2223 zprint2("Last saved in ZQuest Version: 2.10.x");
2224 if ( tempheader.build ) zprint2("Beta/Build %d\n", tempheader.build);
2225 break;
2226 }
2227 /* These versions cannot be handled here; they will be incorrect at this time. -Z
2228 case 0x193:
2229 {
2230 zprint2("Last saved in ZQuest Version: 1.93, Beta %d\n", tempheader.build); break;
2231 }
2232 case 0x192:
2233 {
2234 zprint2("Last saved in ZQuest Version: 1.92, Beta %d\n", tempheader.build); break;
2235 }
2236 case 0x190:
2237 {
2238 zprint2("Last saved in ZQuest Version: 1.90, Beta/Build %d\n", tempheader.build); break;
2239 }
2240 case 0x184:
2241 {
2242 zprint2("Last saved in ZQuest Version: 1.84, Beta/Build %d\n", tempheader.build); break;
2243 }
2244 case 0x183:
2245 {
2246 zprint2("Last saved in ZQuest Version: 1.83, Beta/Build %d\n", tempheader.build); break;
2247 }
2248 case 0x180:
2249 {
2250 zprint2("Last saved in ZQuest Version: 1.80, Beta/Build %d\n", tempheader.build); break;
2251 }
2252 default:
2253 {
2254 zprint2("Last saved in ZQuest Version: %x, Beta %d\n", tempheader.zelda_version,tempheader.build); break;
2255 }
2256 */
2257 }
2258 }
2259
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
101 if(!tempheader.is_legacy() && tempheader.getAlphaVer())
2260 17 zprint2("%s\n", tempheader.getAlphaVerStr());
2261 84 else zprint2("\n");
2262
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 17 times.
101 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2263
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 17 times.
101 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2264
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 17 times.
101 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2265
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 17 times.
101 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2266
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 97 times.
101 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2267
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 17 times.
101 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2268 101 zprint2("\n");
2269 101 }
2270
2271 109 int32_t readheader(PACKFILE *f, zquestheader *Header, bool keepdata, byte printmetadata)
2272 {
2273 int32_t dummy;
2274 zquestheader tempheader;
2275 char dummybuf[80];
2276 byte temp_map_count;
2277 byte temp_midi_flags[MIDIFLAGS_SIZE];
2278 word version;
2279 char temp_pwd[30], temp_pwd2[30];
2280 int16_t temp_pwdkey;
2281 cvs_MD5Context ctx;
2282 109 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2283 109 memset(&tempheader, 0, sizeof(tempheader));
2284 109 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2285
2286
2287
2288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f,true)) // first read old header
2289 {
2290 Z_message("Unable to read header string\n");
2291 return qe_invalid;
2292 }
2293
2294 // check header
2295
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
109 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2296 {
2297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2298 {
2299 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2300 return qe_invalid;
2301 }
2302 4 }
2303
2304 109 int32_t templatepath_len=0;
2305
2306 109 tempheader.external_zinfo = false;
2307 109 read_zinfo = false;
2308
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
109 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2309 {
2310 byte padding;
2311
2312
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f,true))
2313 {
2314 return qe_invalid;
2315 }
2316
2317
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.zelda_version,f,true))
2318 {
2319 return qe_invalid;
2320 }
2321
2322 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2323
2324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version > ZELDA_VERSION)
2325 {
2326 return qe_version;
2327 }
2328
2329 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2330
2331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2332 {
2333 return qe_invalid;
2334 }
2335
2336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(bad_version(tempheader.zelda_version))
2337 {
2338 return qe_obsolete;
2339 }
2340
2341
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.internal,f,true))
2342 {
2343 return qe_invalid;
2344 }
2345
2346
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.quest_number,f,true))
2347 {
2348 return qe_invalid;
2349 }
2350
2351 4 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2352
2353
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[0],2,f,true))
2354 {
2355 return qe_invalid;
2356 }
2357
2358
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_map_count,f,true))
2359 {
2360 return qe_invalid;
2361 }
2362
2363 4 FFCore.quest_format[qMapCount] = temp_map_count;
2364
2365
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.old_str_count,f,true))
2366 {
2367 return qe_invalid;
2368 }
2369
2370
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2371 {
2372 return qe_invalid;
2373 }
2374
2375
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_midi_flags,4,f,true))
2376 {
2377 return qe_invalid;
2378 }
2379
2380
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2381 {
2382 return qe_invalid;
2383 }
2384
2385
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,14,f,true))
2386 {
2387 return qe_invalid;
2388 }
2389
2390
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[2],2,f,true))
2391 {
2392 return qe_invalid;
2393 }
2394
2395
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&dummybuf,f,true))
2396 {
2397 return qe_invalid;
2398 }
2399
2400
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.version,9,f,true))
2401 {
2402 return qe_invalid;
2403 }
2404
2405
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2406 {
2407 return qe_invalid;
2408 }
2409 // These fields are expected to end in null bytes!
2410 4 tempheader.title[sizeof(tempheader.title)-1] = 0;
2411
2412
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2413 {
2414 return qe_invalid;
2415 }
2416 4 tempheader.author[sizeof(tempheader.author)-1] = 0;
2417
2418
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f,true))
2419 {
2420 return qe_invalid;
2421 }
2422
2423
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&temp_pwdkey,f,true))
2424 {
2425 return qe_invalid;
2426 }
2427
2428
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_pwd,30,f,true))
2429 {
2430 return qe_invalid;
2431 }
2432
2433 4 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2434 4 cvs_MD5Init(&ctx);
2435 4 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2436 4 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2437
2438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2439 {
2440 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2441 // Not anymore...
2442 memset(tempheader.minver,0,17);
2443 tempheader.build=0;
2444 tempheader.use_keyfile=0;
2445 memset(tempheader.old_foo, 0, 9);
2446 }
2447 else
2448 {
2449
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.minver,9,f,true))
2450 {
2451 return qe_invalid;
2452 }
2453
2454
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.build,f,true))
2455 {
2456 return qe_invalid;
2457 }
2458
2459 4 FFCore.quest_format[vBuild] = tempheader.build;
2460
2461
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.use_keyfile,f,true))
2462 {
2463 return qe_invalid;
2464 }
2465
2466
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,9,f,true))
2467 {
2468 return qe_invalid;
2469 }
2470 } // starting at minver
2471
2472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2473 {
2474 memset(&quest_rules[4],0,16); // word rules3..rules10
2475 }
2476 else
2477 {
2478
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[4],16,f,true)) // read new header additions
2479 {
2480 return qe_invalid; // starting at rules3
2481 }
2482
2483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version <= 0x190)
2484 {
2485 4 set_bit(quest_rules,qr_MEANPLACEDTRAPS,0);
2486 4 }
2487 }
2488
2489
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2490 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2491 {
2492 4 set_bit(quest_rules,qr_BRKNSHLDTILES,(get_bit(quest_rules,qr_BRKBLSHLDS_DEP)));
2493 4 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2494 4 }
2495
2496
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2497 {
2498 byte *mf=temp_midi_flags;
2499
2500 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2501 {
2502 mf=(byte*)dummybuf;
2503 }
2504
2505 if(!pfread(mf,32,f,true)) // read new header additions
2506 {
2507 return qe_invalid; // starting at foo2
2508 }
2509
2510 if(!pfread(dummybuf,18,f,true)) // read new header additions
2511 {
2512 return qe_invalid; // starting at foo2
2513 }
2514 }
2515
2516
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2517 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2518 {
2519 4 memset(tempheader.templatepath,0,2048);
2520 4 }
2521 else
2522 {
2523 if(!pfread(tempheader.templatepath,280,f,true)) // read templatepath
2524 {
2525 return qe_invalid;
2526 }
2527 }
2528
2529
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2530 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2531 {
2532 4 tempheader.use_keyfile=0;
2533 4 }
2534 4 }
2535 else
2536 {
2537 //section id
2538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(!p_mgetl(&dummy,f,true))
2539 {
2540 return qe_invalid;
2541 }
2542
2543 //section version info
2544
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&version,f,true))
2545 {
2546 return qe_invalid;
2547 }
2548
2549 105 FFCore.quest_format[vHeader] = version;
2550
2551
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&dummy,f,true))
2552 {
2553 return qe_invalid;
2554 }
2555
2556 //section size
2557
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy,f,true))
2558 {
2559 return qe_invalid;
2560 }
2561
2562 //finally... section data
2563
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&tempheader.zelda_version,f,true))
2564 {
2565 return qe_invalid;
2566 }
2567
2568 105 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2569
2570 //do some quick checking...
2571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(tempheader.zelda_version > ZELDA_VERSION)
2572 {
2573 return qe_version;
2574 }
2575
2576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2577 {
2578 return qe_invalid;
2579 }
2580
2581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(bad_version(tempheader.zelda_version))
2582 {
2583 return qe_obsolete;
2584 }
2585
2586
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&tempheader.build,f,true))
2587 {
2588 return qe_invalid;
2589 }
2590
2591 105 FFCore.quest_format[vBuild] = tempheader.build;
2592
2593
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 100 times.
105 if(version<3)
2594 {
2595
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!pfread(temp_pwd,30,f,true))
2596 {
2597 return qe_invalid;
2598 }
2599
2600
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!p_igetw(&temp_pwdkey,f,true))
2601 {
2602 return qe_invalid;
2603 }
2604
2605 5 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2606 5 cvs_MD5Init(&ctx);
2607 5 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2608 5 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2609 5 }
2610 else
2611 {
2612
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f,true))
2613 {
2614 return qe_invalid;
2615 }
2616 }
2617
2618
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&tempheader.internal,f,true))
2619 {
2620 return qe_invalid;
2621 }
2622
2623
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&tempheader.quest_number,f,true))
2624 {
2625 return qe_invalid;
2626 }
2627
2628 105 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2629
2630 105 size_t versz = version < 8 ? 9 : 16;
2631
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!pfread(tempheader.version,versz,f,true))
2632 {
2633 return qe_invalid;
2634 }
2635
2636 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2637 //needs to be copied as char[9] or stored as a s.str
2638
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!pfread(tempheader.minver,versz,f,true))
2639 {
2640 return qe_invalid;
2641 }
2642
2643 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2644
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2645 {
2646 return qe_invalid;
2647 }
2648 105 tempheader.title[sizeof(tempheader.title)-1] = 0;
2649
2650
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2651 {
2652 return qe_invalid;
2653 }
2654 105 tempheader.author[sizeof(tempheader.author)-1] = 0;
2655
2656
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&tempheader.use_keyfile,f,true))
2657 {
2658 return qe_invalid;
2659 }
2660
2661 /*
2662 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f,true))
2663 {
2664 return qe_invalid;
2665 }
2666 */
2667
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2668 {
2669 return qe_invalid;
2670 }
2671
2672
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!pfread(&dummybuf,4,f,true))
2673 {
2674 return qe_invalid;
2675 }
2676
2677
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2678 {
2679 return qe_invalid;
2680 }
2681
2682
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!pfread(dummybuf,14,f,true))
2683 {
2684 return qe_invalid;
2685 }
2686
2687 105 templatepath_len=sizeof(tempheader.templatepath);
2688
2689
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 5 times.
105 if(version==1)
2690 {
2691 5 templatepath_len=280;
2692 5 }
2693
2694
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!pfread(tempheader.templatepath,templatepath_len,f,true))
2695 {
2696 return qe_invalid;
2697 }
2698
2699
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_getc(&temp_map_count,f,true))
2700 {
2701 return qe_invalid;
2702 }
2703
2704
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 80 times.
105 if(version>=4)
2705 {
2706
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&tempheader.new_version_id_main,f,true))
2707 {
2708 return qe_invalid;
2709 }
2710
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&tempheader.new_version_id_second,f,true))
2711 {
2712 return qe_invalid;
2713 }
2714
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&tempheader.new_version_id_third,f,true))
2715 {
2716 return qe_invalid;
2717 }
2718
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&tempheader.new_version_id_fourth,f,true))
2719 {
2720 return qe_invalid;
2721 }
2722
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&tempheader.new_version_id_alpha,f,true))
2723 {
2724 return qe_invalid;
2725 }
2726
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&tempheader.new_version_id_beta,f,true))
2727 {
2728 return qe_invalid;
2729 }
2730
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&tempheader.new_version_id_gamma,f,true))
2731 {
2732 return qe_invalid;
2733 }
2734
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&tempheader.new_version_id_release,f,true))
2735 {
2736 return qe_invalid;
2737 }
2738
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&tempheader.new_version_id_date_year,f,true))
2739 {
2740 return qe_invalid;
2741 }
2742
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&tempheader.new_version_id_date_month,f,true))
2743 {
2744 return qe_invalid;
2745 }
2746
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&tempheader.new_version_id_date_day,f,true))
2747 {
2748 return qe_invalid;
2749 }
2750
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&tempheader.new_version_id_date_hour,f,true))
2751 {
2752 return qe_invalid;
2753 }
2754
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&tempheader.new_version_id_date_minute,f,true))
2755 {
2756 return qe_invalid;
2757 }
2758
2759
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!pfread(tempheader.new_version_devsig,256,f,true))
2760 {
2761 return qe_invalid;
2762 }
2763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2764 strcpy(tempheader.new_version_devsig, "EmilyV99");
2765
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!pfread(tempheader.new_version_compilername,256,f,true))
2766 {
2767 return qe_invalid;
2768 }
2769
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!pfread(tempheader.new_version_compilerversion,256,f,true))
2770 {
2771 return qe_invalid;
2772 }
2773
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!pfread(tempheader.product_name,1024,f,true))
2774 {
2775 return qe_invalid;
2776 }
2777
2778
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&tempheader.compilerid,f,true))
2779 {
2780 return qe_invalid;
2781 }
2782
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&tempheader.compilerversionnumber_first,f,true))
2783 {
2784 return qe_invalid;
2785 }
2786
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&tempheader.compilerversionnumber_second,f,true))
2787 {
2788 return qe_invalid;
2789 }
2790
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&tempheader.compilerversionnumber_third,f,true))
2791 {
2792 return qe_invalid;
2793 }
2794
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f,true))
2795 {
2796 return qe_invalid;
2797 }
2798
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&tempheader.developerid,f,true))
2799 {
2800 return qe_invalid;
2801 }
2802
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!pfread(tempheader.made_in_module_name,1024,f,true))
2803 {
2804 return qe_invalid;
2805 }
2806
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!pfread(tempheader.build_datestamp,256,f,true))
2807 {
2808 return qe_invalid;
2809 }
2810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(!pfread(tempheader.build_timestamp,256,f,true))
2811 {
2812 return qe_invalid;
2813 }
2814 25 }
2815 else // <4
2816 {
2817 80 tempheader.new_version_id_main = 0;
2818 80 tempheader.new_version_id_second = 0;
2819 80 tempheader.new_version_id_third = 0;
2820 80 tempheader.new_version_id_fourth = 0;
2821 80 tempheader.new_version_id_alpha = 0;
2822 80 tempheader.new_version_id_beta = 0;
2823 80 tempheader.new_version_id_gamma = 0;
2824 80 tempheader.new_version_id_release = 0;
2825 80 tempheader.new_version_id_date_year = 0;
2826 80 tempheader.new_version_id_date_month = 0;
2827 80 tempheader.new_version_id_date_day = 0;
2828 80 tempheader.new_version_id_date_hour = 0;
2829 80 tempheader.new_version_id_date_minute = 0;
2830
2831 80 memset(tempheader.new_version_devsig, 0, 256);
2832 80 memset(tempheader.new_version_compilername, 0, 256);
2833 80 memset(tempheader.new_version_compilerversion, 0, 256);
2834 80 memset(tempheader.product_name, 0, 1024);
2835 80 strcpy(tempheader.product_name, "ZQuest Creator Suite");
2836
2837 80 tempheader.compilerid = 0;
2838 80 tempheader.compilerversionnumber_first = 0;
2839 80 tempheader.compilerversionnumber_second = 0;
2840 80 tempheader.compilerversionnumber_third = 0;
2841 80 tempheader.compilerversionnumber_fourth = 0;
2842 80 tempheader.developerid = 0;
2843
2844 80 memset(tempheader.made_in_module_name, 0, 1024);
2845 80 memset(tempheader.build_datestamp, 0, 256);
2846 80 memset(tempheader.build_timestamp, 0, 256);
2847 }
2848
2849
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 80 times.
105 if ( version >= 5 )
2850 {
2851
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!pfread(tempheader.build_timezone,6,f,true))
2852 {
2853 return qe_invalid;
2854 }
2855 25 }
2856 else // < 5
2857 {
2858 80 memset(tempheader.build_timezone, 0, 6);
2859 }
2860
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 25 times.
105 if ( version >= 6 )
2861 {
2862 byte b;
2863
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&b,f,true))
2864 {
2865 return qe_invalid;
2866 }
2867 25 tempheader.external_zinfo = b?true:false;
2868 25 read_zinfo = true;
2869 25 }
2870
2871
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 80 times.
105 if(version >= 7)
2872 {
2873
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&(tempheader.new_version_is_nightly),f,true))
2874 {
2875 return qe_invalid;
2876 }
2877 25 }
2878 else
2879 {
2880 80 tempheader.new_version_is_nightly = false;
2881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if(tempheader.zelda_version < 0x255)
2882 {
2883
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
80 switch(tempheader.zelda_version)
2884 {
2885 case 0x254:
2886 tempheader.new_version_id_main = 2;
2887 tempheader.new_version_id_second = 54;
2888 break;
2889 case 0x250:
2890
6/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 21 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 24 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 15 times.
✓ Branch 14 taken 9 times.
✓ Branch 15 taken 1 times.
75 switch(tempheader.build)
2891 {
2892 case 19:
2893 tempheader.new_version_id_main = 2;
2894 tempheader.new_version_id_second = 50;
2895 tempheader.new_version_id_gamma = 1;
2896 break;
2897 case 20:
2898 tempheader.new_version_id_main = 2;
2899 tempheader.new_version_id_second = 50;
2900 tempheader.new_version_id_gamma = 2;
2901 break;
2902 case 21:
2903 tempheader.new_version_id_main = 2;
2904 tempheader.new_version_id_second = 50;
2905 tempheader.new_version_id_gamma = 3;
2906 break;
2907 case 22:
2908 tempheader.new_version_id_main = 2;
2909 tempheader.new_version_id_second = 50;
2910 tempheader.new_version_id_gamma = 4;
2911 break;
2912 case 23:
2913 tempheader.new_version_id_main = 2;
2914 tempheader.new_version_id_second = 50;
2915 tempheader.new_version_id_gamma = 5;
2916 break;
2917 case 24:
2918 21 tempheader.new_version_id_main = 2;
2919 21 tempheader.new_version_id_second = 50;
2920 21 tempheader.new_version_id_release = -1;
2921 21 break;
2922 case 25:
2923 tempheader.new_version_id_main = 2;
2924 tempheader.new_version_id_second = 50;
2925 tempheader.new_version_id_third = 1;
2926 tempheader.new_version_id_gamma = 1;
2927 break;
2928 case 26:
2929 tempheader.new_version_id_main = 2;
2930 tempheader.new_version_id_second = 50;
2931 tempheader.new_version_id_third = 1;
2932 tempheader.new_version_id_gamma = 2;
2933 break;
2934 case 27:
2935 tempheader.new_version_id_main = 2;
2936 tempheader.new_version_id_second = 50;
2937 tempheader.new_version_id_third = 1;
2938 tempheader.new_version_id_gamma = 3;
2939 break;
2940 case 28:
2941 5 tempheader.new_version_id_main = 2;
2942 5 tempheader.new_version_id_second = 50;
2943 5 tempheader.new_version_id_third = 1;
2944 5 tempheader.new_version_id_release = -1;
2945 5 break;
2946 case 29:
2947 24 tempheader.new_version_id_main = 2;
2948 24 tempheader.new_version_id_second = 50;
2949 24 tempheader.new_version_id_third = 2;
2950 24 tempheader.new_version_id_release = -1;
2951 24 break;
2952 case 30:
2953 tempheader.new_version_id_main = 2;
2954 tempheader.new_version_id_second = 50;
2955 tempheader.new_version_id_third = 3;
2956 tempheader.new_version_id_gamma = 1;
2957 break;
2958 case 31:
2959 15 tempheader.new_version_id_main = 2;
2960 15 tempheader.new_version_id_second = 53;
2961 15 tempheader.new_version_id_gamma = -1;
2962 15 break;
2963 case 32:
2964 9 tempheader.new_version_id_main = 2;
2965 9 tempheader.new_version_id_second = 53;
2966 9 tempheader.new_version_id_release = -1;
2967 9 break;
2968 case 33:
2969 1 tempheader.new_version_id_main = 2;
2970 1 tempheader.new_version_id_second = 53;
2971 1 tempheader.new_version_id_third = 1;
2972 1 break;
2973 }
2974 75 break;
2975
2976 case 0x211:
2977 tempheader.new_version_id_main = 2;
2978 tempheader.new_version_id_second = 11;
2979 tempheader.new_version_id_beta = tempheader.build;
2980 break;
2981 case 0x210:
2982 5 tempheader.new_version_id_main = 2;
2983 5 tempheader.new_version_id_second = 10;
2984 5 tempheader.new_version_id_beta = tempheader.build;
2985 5 break;
2986 }
2987 80 }
2988 }
2989
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
105 if(printmetadata || __isZQuest)
2990 {
2991 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2992 }
2993 }
2994
2995 //{ Version Warning
2996 109 int32_t vercmp = tempheader.compareVer();
2997 109 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), ALPHA_STATE);
2998 109 int32_t avercmp = compare(tempheader.getAlphaVer(), ALPHA_VER);
2999
4/6
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
134 if(vercmp > 0 || (!vercmp &&
3000
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 (astatecmp > 0 || (!astatecmp &&
3001 25 avercmp > 0))))
3002 {
3003 bool r = true;
3004 if(loadquest_report)
3005 {
3006 enter_sys_pal();
3007 AlertDialog("Quest saved in newer version",
3008 "This quest was last saved in a newer version of ZQuest."
3009 " Attempting to load this quest may not work correctly; to"
3010 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
3011 "\n\nWould you like to continue loading anyway? (Not recommended)",
3012 [&](bool ret,bool)
3013 {
3014 r = ret;
3015 }).show();
3016 exit_sys_pal();
3017 }
3018 if(!r)
3019 return qe_silenterr;
3020 }
3021
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 else if(tempheader.compareDate() > 0)
3022 {
3023 bool r = true;
3024 if(loadquest_report)
3025 {
3026 enter_sys_pal();
3027 AlertDialog("Quest saved in newer build",
3028 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
3029 " issues loading in this build."
3030 "\n{}"
3031 "\n\nWould you like to continue loading anyway?",
3032 tempheader.getVerCmpStr()),
3033 [&](bool ret,bool)
3034 {
3035 r = ret;
3036 }).show();
3037 exit_sys_pal();
3038 }
3039 if(!r)
3040 return qe_silenterr;
3041 }
3042 //}
3043
3044 109 read_ext_zinfo = tempheader.external_zinfo;
3045
3046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(keepdata==true)
3047 {
3048 109 memcpy(Header, &tempheader, sizeof(tempheader));
3049 109 map_count=temp_map_count;
3050 109 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
3051 109 }
3052
3053 109 return 0;
3054 109 }
3055
3056 111 int32_t readrules(PACKFILE *f, zquestheader *Header, bool keepdata)
3057 {
3058 int32_t dummy;
3059 zquestheader tempheader;
3060 111 word s_version=0;
3061 111 dword compatrule_version=0;
3062
3063 111 memcpy(&tempheader, Header, sizeof(tempheader));
3064
3065
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 105 times.
111 if(tempheader.zelda_version >= 0x193)
3066 {
3067 //section version info
3068
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_version,f,true))
3069 {
3070 return qe_invalid;
3071 }
3072
3073 105 FFCore.quest_format[vRules] = s_version;
3074
3075
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&dummy,f,true))
3076 {
3077 return qe_invalid;
3078 }
3079
3080
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 25 times.
105 if(s_version > 16)
3081 {
3082
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&compatrule_version,f,true))
3083 {
3084 return qe_invalid;
3085 }
3086 25 }
3087 105 FFCore.quest_format[vCompatRule] = compatrule_version;
3088
3089 //section size
3090
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy,f,true))
3091 {
3092 return qe_invalid;
3093 }
3094
3095
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 25 times.
105 if ( s_version < 15 )
3096 {
3097 //finally... section data
3098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if(!pfread(quest_rules,QUESTRULES_SIZE,f,true))
3099 {
3100 return qe_invalid;
3101 }
3102 80 }
3103 else
3104 {
3105
3106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f,true))
3107 {
3108 return qe_invalid;
3109 }
3110
3111 }
3112 105 }
3113
3114 //al_trace("Rules version %d\n", s_version);
3115 //{ bunch of compat stuff
3116 111 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
3117
3118
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 9 times.
111 if(s_version<2)
3119 {
3120 9 set_bit(quest_rules,14,0);
3121 9 set_bit(quest_rules,27,0);
3122 9 set_bit(quest_rules,28,0);
3123 9 set_bit(quest_rules,29,0);
3124 9 set_bit(quest_rules,30,0);
3125 9 set_bit(quest_rules,32,0);
3126 9 set_bit(quest_rules,36,0);
3127 9 set_bit(quest_rules,49,0);
3128 9 set_bit(quest_rules,50,0);
3129 9 set_bit(quest_rules,51,0);
3130 9 set_bit(quest_rules,68,0);
3131 9 set_bit(quest_rules,75,0);
3132 9 set_bit(quest_rules,76,0);
3133 9 set_bit(quest_rules,98,0);
3134 9 set_bit(quest_rules,110,0);
3135 9 set_bit(quest_rules,113,0);
3136 9 set_bit(quest_rules,116,0);
3137 9 set_bit(quest_rules,102,0);
3138 9 set_bit(quest_rules,132,0);
3139 9 }
3140
3141 //Now, do any updates...
3142
5/6
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
111 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
3143 {
3144 13 set_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING,1);
3145 13 set_bit(quest_rules, qr_REPLACEOPENDOORS, 1);
3146 13 set_bit(quest_rules, qr_OLDLENSORDER, 1);
3147 13 set_bit(quest_rules, qr_NOFAIRYGUYFIRES, 1);
3148 13 set_bit(quest_rules, qr_TRIGGERSREPEAT, 1);
3149 13 }
3150
3151
5/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
111 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3152 {
3153 8 set_bit(quest_rules,qr_WALLFLIERS,1);
3154 8 }
3155
3156
5/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
111 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
3157 {
3158 8 set_bit(quest_rules,qr_NOBOMBPALFLASH,1);
3159 8 }
3160
3161
5/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
111 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3162 {
3163 8 set_bit(quest_rules,qr_NOSCROLLCONTINUE,1);
3164 8 }
3165
3166
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 9 times.
111 if(tempheader.zelda_version <= 0x210)
3167 {
3168 9 set_bit(quest_rules,qr_ARROWCLIP,1);
3169 9 }
3170
3171
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 5 times.
111 if(tempheader.zelda_version == 0x210)
3172 {
3173 5 set_bit(quest_rules, qr_NOSCROLLCONTINUE, get_bit(quest_rules, qr_CMBCYCLELAYERS));
3174 5 set_bit(quest_rules, qr_CMBCYCLELAYERS, 0);
3175 5 set_bit(quest_rules, qr_CONT_SWORD_TRIGGERS, 1);
3176 5 }
3177
3178
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 9 times.
111 if(tempheader.zelda_version <= 0x210)
3179 {
3180 9 set_bit(quest_rules,qr_OLDSTYLEWARP,1);
3181 9 set_bit(quest_rules,qr_210_WARPRETURN,1);
3182 9 }
3183
3184 //might not be correct
3185
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 4 times.
111 if(tempheader.zelda_version < 0x210)
3186 {
3187 4 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
3188 4 set_bit(quest_rules, qr_OLDHOOKSHOTGRAB,1);
3189 4 }
3190
3191
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 9 times.
111 if(tempheader.zelda_version < 0x211)
3192 {
3193 9 set_bit(quest_rules, qr_WRONG_BRANG_TRAIL_DIR,1);
3194 9 }
3195
3196
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
111 if(tempheader.zelda_version == 0x192 && tempheader.build == 163)
3197 {
3198 set_bit(quest_rules, qr_192b163_WARP,1);
3199 }
3200
3201
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 5 times.
111 if(tempheader.zelda_version == 0x210)
3202 {
3203 5 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_bit(quest_rules, qr_DMGCOMBOPRI));
3204 5 set_bit(quest_rules, qr_DMGCOMBOPRI, 0);
3205 5 }
3206
3207
5/6
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
111 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3208 {
3209 13 set_bit(quest_rules, qr_OLDPICKUP,1);
3210 13 }
3211
3212
5/6
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
111 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3213 {
3214 13 set_bit(quest_rules,qr_NOSOLIDDAMAGECOMBOS, 1);
3215 13 set_bit(quest_rules, qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3216 13 }
3217
3218
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 9 times.
111 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3219 {
3220 9 set_bit(quest_rules,qr_HOOKSHOTDOWNBUG, 1);
3221 9 }
3222
3223
4/4
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 21 times.
111 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3224 {
3225 21 set_bit(quest_rules,qr_PEAHATCLOCKVULN, 1);
3226 21 }
3227
3228
6/6
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 77 times.
111 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3229 {
3230 13 set_bit(quest_rules,qr_OLD_DOORREPAIR, 1);
3231 13 }
3232
3233
6/6
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 77 times.
111 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3234 {
3235 13 set_bit(quest_rules,qr_OLD_SECRETMONEY, 1);
3236 13 }
3237
3238
6/6
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 23 times.
✓ Branch 5 taken 56 times.
111 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3239 {
3240 34 set_bit(quest_rules,qr_OLD_POTION_OR_HC, 1);
3241 34 }
3242
3243
6/6
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 23 times.
✓ Branch 5 taken 56 times.
111 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3244 {
3245 34 set_bit(quest_rules, qr_OFFSCREENWEAPONS, 1);
3246 34 }
3247
3248 //Bombchu fix.
3249
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 75 times.
111 if(tempheader.zelda_version == 0x250)
3250 {
3251
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 21 times.
75 if ( tempheader.build == 24 ) //2.50.0
3252 {
3253 21 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3254 21 }
3255
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 5 times.
75 if ( tempheader.build == 28 ) //2.50.1
3256 {
3257 5 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3258 5 }
3259
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 24 times.
75 if ( tempheader.build == 29 ) //2.50.2
3260 {
3261 24 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3262 24 }
3263
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if ( tempheader.build == 30 ) //2.50.3RC1
3264 {
3265 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3266 }
3267 75 }
3268
3269
6/6
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 51 times.
111 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3270 {
3271 // qr_OFFSETEWPNCOLLISIONFIX
3272 // All 'official' quests need this disabled.
3273 // All 2.10 and lower quests need this enabled to preseve compatability.
3274 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3275
3276 //~Gleeok
3277 35 set_bit(quest_rules, qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3278
3279 // Broke in build 695
3280
3/4
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26 times.
35 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3281 26 set_bit(quest_rules, qr_BROKENSTATUES, 1);
3282 35 }
3283
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 4 times.
111 if (tempheader.zelda_version <= 0x190)
3284 {
3285 4 set_bit(quest_rules, qr_COPIED_SWIM_SPRITES, 1);
3286 4 }
3287
9/10
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 26 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 25 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 25 times.
111 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3288 {
3289 85 set_bit(quest_rules, qr_OLD_SLASHNEXT_SECRETS, 1);
3290 85 }
3291
3292
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
109 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3293 {
3294 9 set_bit(quest_rules, qr_OLD_210_WATER, 1);
3295 9 }
3296
3297
4/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
109 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3298 {
3299 84 set_bit(quest_rules,qr_STEP_IS_FLOAT,0);
3300 84 }
3301
3302
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
109 if ( tempheader.zelda_version < 0x250 )
3303 {
3304 9 set_bit(quest_rules, qr_8WAY_SHOT_SFX, 1);
3305 9 }
3306
3307
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
109 if(s_version < 3)
3308 {
3309 9 set_bit(quest_rules, qr_HOLDNOSTOPMUSIC, 1);
3310 9 set_bit(quest_rules, qr_CAVEEXITNOSTOPMUSIC, 1);
3311 9 }
3312
3313
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
109 if(s_version<4)
3314 {
3315 9 set_bit(quest_rules,10,0);
3316 9 }
3317
3318
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
109 if(s_version<5)
3319 {
3320 9 set_bit(quest_rules,27,0);
3321 9 }
3322
3323
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
109 if(s_version<6)
3324 {
3325 9 set_bit(quest_rules,46,0);
3326 9 }
3327
3328
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
109 if(s_version<7) // January 2008
3329 {
3330 9 set_bit(quest_rules,qr_HEARTSREQUIREDFIX,0);
3331 9 set_bit(quest_rules,qr_PUSHBLOCKCSETFIX,1);
3332 9 }
3333
3334
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 100 times.
109 if(s_version<8)
3335 {
3336 9 set_bit(quest_rules, 12, 0);
3337 9 }
3338 else
3339 {
3340 100 set_bit(deprecated_rules, 12, 0);
3341 }
3342
3343
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
109 if(s_version<9) // October 2008
3344 {
3345 9 set_bit(quest_rules,qr_NOROPE2FLASH_DEP,0);
3346 9 set_bit(quest_rules,qr_NOBUBBLEFLASH_DEP,0);
3347 9 set_bit(quest_rules,qr_GHINI2BLINK_DEP,0);
3348 9 set_bit(quest_rules,qr_PHANTOMGHINI2_DEP,0);
3349 9 }
3350
3351
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
109 if(s_version<10) // December 2008
3352 {
3353 9 set_bit(quest_rules,qr_NOCLOCKS_DEP,0);
3354 9 set_bit(quest_rules, qr_ALLOW10RUPEEDROPS_DEP,0);
3355 9 }
3356
3357
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
109 if(s_version<11) // April 2009
3358 {
3359 9 set_bit(quest_rules,qr_SLOWENEMYANIM_DEP,0);
3360 9 }
3361
3362
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
109 if(s_version<12) // December 2009
3363 {
3364 9 set_bit(quest_rules,qr_BRKBLSHLDS_DEP,0);
3365 9 set_bit(quest_rules, qr_OLDTRIBBLES_DEP,0);
3366 9 }
3367
3368 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3369
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
109 if(s_version < 13)
3370 {
3371 9 set_bit(quest_rules,qr_SHOPCHEAT, 1);
3372 9 }
3373
3374 // Not entirely sure this is the best place for this...
3375 //2.50.2 bitmap offset fix
3376 109 memset(extra_rules, 0, EXTRARULES_SIZE);
3377
6/6
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 26 times.
✓ Branch 5 taken 49 times.
109 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3378 {
3379 35 set_bit(extra_rules, er_BITMAPOFFSET, 1);
3380 35 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 1);
3381 35 }
3382 //required because quest templates also used this bit, although
3383 //it never did anything, before. -Z
3384
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 75 times.
109 if ( tempheader.zelda_version == 0x250 )
3385 {
3386
5/6
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 51 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 36 times.
75 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3387 {
3388 39 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3389 39 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3390 39 }
3391 75 }
3392
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if ( tempheader.zelda_version == 0x254 )
3393 {
3394 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3395 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3396 }
3397
3/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
109 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3398 {
3399 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3400 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3401 }
3402 //optimise fast drawing for older versions.
3403
4/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
109 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3404 {
3405 84 set_bit(quest_rules, qr_OLDSPRITEDRAWS, 1);
3406 84 }
3407 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3408 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3409 //older quests can set the rule by hand. We need a new qst.dat again.
3410
4/6
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
109 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3411 {
3412 set_bit(quest_rules, qr_OLDEWPNPARENT, 1);
3413 }
3414
4/6
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
109 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3415 {
3416 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 1);
3417 }
3418
4/6
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
109 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3419 {
3420 set_bit(quest_rules, qr_OLDQUESTMISC, 1);
3421 }
3422
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if ( tempheader.zelda_version < 0x254 )
3423 {
3424 84 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 0);
3425 84 set_bit(quest_rules, qr_OLDEWPNPARENT, 0);
3426 84 set_bit(quest_rules, qr_OLDQUESTMISC, 0);
3427 84 }
3428
3429 //item scripts continue to run
3430
4/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
109 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3431 {
3432 84 set_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING, 0);
3433 84 set_bit(quest_rules, qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3434 84 set_bit(quest_rules, qr_FIXSCRIPTSDURINGSCROLLING, 0);
3435 84 set_bit(quest_rules, qr_SCRIPTDRAWSINWARPS, 0);
3436 84 set_bit(quest_rules, qr_DYINGENEMYESDONTHURTHERO, 0);
3437 84 set_bit(quest_rules, qr_OUTOFBOUNDSENEMIES, 0);
3438 84 set_bit(quest_rules, qr_SPRITEXY_IS_FLOAT, 0);
3439 84 }
3440
3441
4/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
109 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3442 {
3443 84 set_bit(quest_rules, qr_CLEARINITDONSCRIPTCHANGE, 1);
3444 84 }
3445
4/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
109 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3446 {
3447 84 set_bit(quest_rules, qr_TRACESCRIPTIDS, 0);
3448 84 set_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3449 84 set_bit(quest_rules, qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3450 84 set_bit(quest_rules,qr_PARSER_250DIVISION,1);
3451 84 set_bit(quest_rules,qr_PARSER_BOOL_TRUE_DECIMAL,1);
3452 84 set_bit(quest_rules,qr_PARSER_TRUE_INT_SIZE,0);
3453 84 set_bit(quest_rules,qr_PARSER_FORCE_INLINE,0);
3454 84 set_bit(quest_rules,qr_PARSER_BINARY_32BIT,0);
3455
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 1 times.
84 if ( get_bit(quest_rules, qr_SELECTAWPN) )
3456 {
3457 1 set_bit(quest_rules,qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3458 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3459 //Now they **do**, unless you disable that behaviour.
3460 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3461 //now enable the disable L/R item swap on load.
3462 1 }
3463
3464 84 }
3465
4/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
109 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3466 {
3467 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3468 84 set_bit(quest_rules, qr_DISALLOW_SETTING_RAFTING, 1);
3469 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3470 //animations ending earlier than they should.
3471 84 set_bit(quest_rules, qr_BROKEN_ASKIP_Y_FRAMES, 1);
3472 //Enemies would ignore solidity on the top half of combos
3473 84 set_bit(quest_rules, qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3474 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3475 84 set_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3476 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3477 84 set_bit(quest_rules, qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3478 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3479 84 set_bit(quest_rules, qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3480 84 }
3481
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if ( tempheader.zelda_version < 0x255 )
3482 {
3483 84 set_bit(quest_rules, qr_NOFFCWAITDRAW, 1);
3484 84 set_bit(quest_rules, qr_NOITEMWAITDRAW, 1);
3485 84 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3486 84 set_bit(quest_rules, qr_OLD_INIT_SCRIPT_TIMING, 1);
3487 //set_bit(quest_rules, qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3488 84 }
3489
4/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
109 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3490 {
3491 84 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3492 84 }
3493
4/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
109 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3494 {
3495 84 set_bit(quest_rules, qr_OLD_PRINTF_ARGS, 1);
3496 84 }
3497
3498
3499
4/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
109 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3500 {
3501 84 set_bit(quest_rules, qr_BROKEN_RING_POWER, 1);
3502 84 }
3503
4/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
109 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3504 {
3505 84 set_bit(quest_rules, qr_NO_OVERWORLD_MAP_CHARTING, 1);
3506 84 }
3507
4/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
109 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3508 {
3509 84 set_bit(quest_rules, qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3510 84 }
3511
4/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
109 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3512 {
3513 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3514
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS))
3515 set_bit(quest_rules,qr_SET_YBUTTON_ITEMS,1);
3516 84 }
3517
4/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
109 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3518 {
3519 84 set_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0,1);
3520 84 }
3521
4/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
109 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3522 {
3523 84 set_bit(quest_rules,qr_OLD_CHEST_COLLISION,1);
3524 84 }
3525
3526
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if ( tempheader.zelda_version < 0x254 )
3527 {
3528 84 set_bit(quest_rules, qr_250WRITEEDEFSCRIPT, 1);
3529 84 }
3530 //Sideview spikes in 2.50.0
3531
6/6
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 21 times.
✓ Branch 5 taken 54 times.
109 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3532 {
3533 30 set_bit(quest_rules, qr_OLDSIDEVIEWSPIKES, 1);
3534 30 }
3535 //more 2.50 fixes -Z
3536
6/6
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 50 times.
✓ Branch 5 taken 25 times.
109 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3537 {
3538 59 set_bit(quest_rules, qr_MELEEMAGICCOST, 0);
3539 59 set_bit(quest_rules, qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3540 59 set_bit(quest_rules, qr_OLDMIRRORCOMBOS, 1);
3541 59 set_bit(quest_rules, qr_BROKENBOOKCOST, 1);
3542 59 set_bit(quest_rules, qr_BROKENCHARINTDRAWING, 1);
3543
3544 59 }
3545
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
109 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3546 {
3547 //set_bit(quest_rules,qr_MELEEMAGICCOST, get_bit(extra_rules,er_MAGICCOSTSWORD));
3548 set_bit(quest_rules,qr_MELEEMAGICCOST, 1);
3549 }
3550
3551
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
109 if(tempheader.zelda_version < 0x193)
3552 {
3553 4 set_bit(quest_rules, qr_SHORTDGNWALK, 1);
3554 4 }
3555
3556
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(tempheader.zelda_version < 0x255)
3557 {
3558 84 set_bit(quest_rules, qr_OLDINFMAGIC, 1);
3559 84 }
3560
3561
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
109 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3562 {
3563 9 set_bit(quest_rules,qr_SIDEVIEWTRIFORCECELLAR,1);
3564 9 }
3565
3566
4/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
109 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3567 {
3568 84 set_bit(quest_rules,qr_OLD_F6,1);
3569 84 }
3570
4/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
109 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3571 {
3572 84 set_bit(quest_rules,qr_NO_OVERWRITING_HOPPING,1);
3573 84 }
3574
4/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
109 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3575 {
3576 84 set_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3577 84 }
3578
4/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
109 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3579 {
3580 84 set_bit(quest_rules,qr_BROKEN_OVERWORLD_MINIMAP,1);
3581 84 }
3582 //}
3583
3584
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3585 84 set_bit(quest_rules,qr_ENEMIES_SECRET_ONLY_16_31,1);
3586
3587
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 2) //Old CSet2 Handling
3588 84 set_bit(quest_rules,qr_OLDCS2,1);
3589
3590
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3591 84 set_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS,1);
3592
3593
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3594 84 set_bit(quest_rules,qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3595
3596
4/4
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 75 times.
109 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3597 75 set_bit(quest_rules,qr_NO_LANMOLA_RINGLEADER,1);
3598
3599
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3600 84 set_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31,1);
3601
3602
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3603 84 set_bit(quest_rules,qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3604
3605
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3606 84 set_bit(quest_rules,qr_HARDCODED_LITEM_LTMS,1);
3607
3608
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 9)
3609 {
3610 //Hardcoded BS Patras
3611 84 set_bit(quest_rules,qr_HARDCODED_BS_PATRA,1);
3612 //Hardcoded Patra Inner Eye offsets
3613 84 set_bit(quest_rules,qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3614 //Broken 'Big enemy' animation style
3615 84 set_bit(quest_rules,qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3616 //Broken Attribute 31/32
3617 84 set_bit(quest_rules,qr_BROKEN_ATTRIBUTE_31_32,1);
3618 84 }
3619
3620
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 10) //Shared candle use limits
3621 84 set_bit(quest_rules,qr_CANDLES_SHARED_LIMIT,1);
3622
3623
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 11) //No cross-screen return points
3624 84 set_bit(quest_rules,qr_OLD_RESPAWN_POINTS,1);
3625
3626
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 12)
3627 {
3628 //Old fire trail duration
3629 84 set_bit(quest_rules,qr_OLD_FLAMETRAIL_DURATION,1);
3630 //Old Intro String in Ganon Room Behavior
3631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if(get_bit(quest_rules,qr_GANONINTRO)) set_bit(quest_rules,qr_GANONINTRO,0);
3632 84 else set_bit(quest_rules,qr_GANONINTRO,1);
3633 84 }
3634
3635
3/4
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 84 times.
✗ Branch 3 not taken.
109 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3636 set_bit(quest_rules,qr_ANONE_NOANIM,1);
3637
3638
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 14) //Old Bridge Combo Behavior
3639 84 set_bit(quest_rules,qr_OLD_BRIDGE_COMBOS,1);
3640
3641
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 15) //Broken Z3 Animation
3642 84 set_bit(quest_rules,qr_BROKEN_Z3_ANIMATION,1);
3643
3644
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3645 84 set_bit(quest_rules,qr_OLD_TILE_INITIALIZATION,1);
3646
3647
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 17)
3648 {
3649 //Old Quake/DrawYOffset behavior
3650 //set_bit(quest_rules,qr_OLD_DRAWOFFSET,1);
3651 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3652 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3653 84 }
3654
3655
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 18)
3656 {
3657 //Broken DrawScreen Derivative Functions
3658 84 set_bit(quest_rules,qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3659 //Scrolling Cancels Charge
3660 84 set_bit(quest_rules,qr_SCROLLING_KILLS_CHARGE,1);
3661 84 }
3662
3663
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3664 84 set_bit(quest_rules,qr_BROKEN_ITEM_CARRYING,1);
3665
3666
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 20)
3667 84 set_bit(quest_rules,qr_CUSTOMWEAPON_IGNORE_COST,1);
3668
3669
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 21)
3670 {
3671 84 set_bit(quest_rules,qr_LEEVERS_DONT_OBEY_STUN,1);
3672 84 set_bit(quest_rules,qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3673 84 set_bit(quest_rules,qr_WIZZROBES_DONT_OBEY_STUN,1);
3674 84 set_bit(quest_rules,qr_OLD_BUG_NET,1);
3675 84 set_bit(quest_rules,qr_MANHANDLA_BLOCK_SFX,1);
3676 84 }
3677
3678
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 22)
3679 84 set_bit(quest_rules,qr_BROKEN_KEEPOLD_FLAG,1);
3680
3681
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 23)
3682 84 set_bit(quest_rules,qr_OLD_HALF_MAGIC,1);
3683
3684
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 24)
3685 {
3686 84 set_bit(quest_rules,qr_WARPS_RESTART_DMAPSCRIPT,1);
3687 84 set_bit(quest_rules,qr_DMAP_0_CONTINUE_BUG,1);
3688 84 }
3689
3690
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 25)
3691 {
3692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if (get_bit(quest_rules, qr_OLD_FAIRY_LIMIT)) set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,0);
3693 84 else set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,1);
3694 84 set_bit(quest_rules,qr_OLD_SCRIPTED_KNOCKBACK,1);
3695 84 }
3696
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 26)
3697 {
3698 84 set_bit(quest_rules,qr_OLD_KEESE_Z_AXIS,1);
3699 84 set_bit(quest_rules,qr_POLVIRE_NO_SHADOW,1);
3700 84 set_bit(quest_rules,qr_SUBSCR_OLD_SELECTOR,1);
3701 84 }
3702
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3703 {
3704
2/2
✓ Branch 0 taken 25284 times.
✓ Branch 1 taken 84 times.
25368 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3705 25284 set_bit(quest_rules,q,0);
3706
2/2
✓ Branch 0 taken 9408 times.
✓ Branch 1 taken 84 times.
9492 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < QUESTRULES_NEW_SIZE*8; ++q)
3707 9408 set_bit(quest_rules,q,0);
3708 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3709 84 }
3710
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 86 times.
109 if(compatrule_version < 28)
3711 86 set_bit(quest_rules,qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3712
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 86 times.
109 if(compatrule_version < 29)
3713 86 set_bit(quest_rules,qr_OLD_LOCKBLOCK_COLLISION,1);
3714
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 86 times.
109 if(compatrule_version < 30)
3715 {
3716 86 set_bit(quest_rules,qr_DECO_2_YOFFSET,1);
3717 86 set_bit(quest_rules,qr_SCREENSTATE_80s_BUG,1);
3718 86 }
3719
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 86 times.
109 if(compatrule_version < 31)
3720 {
3721 86 set_bit(quest_rules,qr_GOHMA_UNDAMAGED_BUG,1);
3722 86 set_bit(quest_rules,qr_FFCPRELOAD_BUGGED_LOAD,1);
3723 86 }
3724
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 86 times.
109 if(compatrule_version < 32)
3725 86 set_bit(quest_rules,qr_BROKEN_GETPIXEL_VALUE,1);
3726
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 86 times.
109 if(compatrule_version < 33)
3727 86 set_bit(quest_rules,qr_NO_LIFT_SPRITE,1);
3728
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 88 times.
109 if(compatrule_version < 34)
3729 {
3730 88 set_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE,1);
3731 88 set_bit(quest_rules,qr_OLD_FFC_SPEED_CAP,1);
3732 88 set_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY,1);
3733 88 set_bit(quest_rules,qr_OLD_WIZZROBE_SUBMERGING,1);
3734 88 }
3735
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 89 times.
109 if(compatrule_version < 35)
3736 {
3737 // Leaving this commented for now, might need to enable later -Em
3738 // set_bit(quest_rules,qr_ZS_NO_NEG_ARRAY,1);
3739 89 }
3740
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 89 times.
109 if(compatrule_version < 36)
3741 89 set_bit(quest_rules,qr_OLD_SHALLOW_SFX,1);
3742
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 99 times.
109 if(compatrule_version < 37)
3743 99 set_bit(quest_rules,qr_SPARKLES_INHERIT_PROPERTIES,1);
3744
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 99 times.
109 if(compatrule_version < 38)
3745 99 set_bit(quest_rules,qr_BUGGED_LAYERED_FLAGS,1);
3746
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 99 times.
109 if(compatrule_version < 39)
3747 99 set_bit(quest_rules,qr_HARDCODED_FFC_BUSH_DROPS,1);
3748
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 99 times.
109 if(compatrule_version < 40)
3749 99 set_bit(quest_rules,qr_MOVINGBLOCK_FAKE_SOLID,1);
3750
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 101 times.
109 if(compatrule_version < 41)
3751 101 set_bit(quest_rules,qr_BROKENHITBY,1);
3752
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 101 times.
109 if(compatrule_version < 42)
3753 101 set_bit(quest_rules,qr_BROKEN_MOVING_BOMBS,1);
3754
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 101 times.
109 if(compatrule_version < 43)
3755 101 set_bit(quest_rules,qr_OLD_BOMB_HITBOXES,1);
3756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(compatrule_version < 44)
3757 109 set_bit(quest_rules,qr_SCROLLWARP_NO_RESET_FRAME,1);
3758
3759 109 set_bit(quest_rules,qr_ANIMATECUSTOMWEAPONS,0);
3760
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if (s_version < 16)
3761 84 set_bit(quest_rules,qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3762
3763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(keepdata==true)
3764 109 memcpy(Header, &tempheader, sizeof(tempheader));
3765
3766 109 return 0;
3767 109 }
3768
3769 905807 void init_msgstr(MsgStr *str)
3770 {
3771 905807 str->s = "";
3772 905807 str->s.shrink_to_fit();
3773 905807 str->nextstring=0;
3774 905807 str->tile=0;
3775 905807 str->cset=0;
3776 905807 str->trans=false;
3777 905807 str->font=font_zfont;
3778 905807 str->y=32;
3779 905807 str->sfx=18;
3780 905807 str->listpos=0;
3781 905807 str->x=24;
3782 905807 str->w=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3783 905807 str->h=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3784 905807 str->hspace=0;
3785 905807 str->vspace=0;
3786 905807 str->stringflags=0;
3787 905807 str->margins[up] = 8;
3788 905807 str->margins[down] = 0;
3789 905807 str->margins[left] = 8;
3790 905807 str->margins[right] = 0;
3791 905807 str->portrait_tile = 0;
3792 905807 str->portrait_cset = 0;
3793 905807 str->portrait_x = 0;
3794 905807 str->portrait_y = 0;
3795 905807 str->portrait_tw = 1;
3796 905807 str->portrait_th = 1;
3797 905807 str->shadow_type = 0;
3798 905807 str->shadow_color = 0;
3799 905807 str->drawlayer = 6;
3800 905807 }
3801
3802 109 void init_msgstrings(int32_t start, int32_t end)
3803 {
3804
2/4
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 109 times.
109 if(end <= start || end-start > msg_strings_size)
3805 return;
3806
3807
2/2
✓ Branch 0 taken 892928 times.
✓ Branch 1 taken 109 times.
893037 for(int32_t i=start; i<end; i++)
3808 {
3809 892928 init_msgstr(&MsgStrings[i]);
3810 892928 MsgStrings[i].listpos=i;
3811 892928 }
3812
3813
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if(start==0)
3814 {
3815 109 MsgStrings[0].s = "(None)";
3816 109 MsgStrings[0].listpos = 0;
3817 109 }
3818 109 }
3819
3820 109 int32_t readstrings(PACKFILE *f, zquestheader *Header, bool keepdata)
3821 {
3822 109 MsgStr tempMsgString;
3823
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 init_msgstr(&tempMsgString);
3824
3825 109 word temp_msg_count=0;
3826 word temp_expansion[16];
3827 109 memset(temp_expansion, 0, 16*sizeof(word));
3828 109 char buf[8193] = {0};
3829
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 105 times.
109 if(Header->zelda_version < 0x193)
3830 {
3831 byte tempbyte;
3832 4 int32_t strings_to_read=0;
3833
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3834
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
3835 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3836 {
3837 4 strings_to_read=128;
3838 4 temp_msg_count=Header->old_str_count;
3839
3840 // Some sort of string count corruption seems to be common in old quests
3841
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(temp_msg_count>128)
3842 {
3843 temp_msg_count=128;
3844 }
3845 4 }
3846 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3847 {
3848 strings_to_read=255;
3849 temp_msg_count=Header->old_str_count;
3850 }
3851 else
3852 {
3853 if(!p_igetw(&temp_msg_count,f,true))
3854 {
3855 return qe_invalid;
3856 }
3857
3858 strings_to_read=temp_msg_count;
3859
3860 if(temp_msg_count >= msg_strings_size)
3861 {
3862 Z_message("Reallocating string buffer...\n");
3863
3864 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3865 // return qe_nomem;
3866
3867 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3868 delete[] MsgStrings;
3869 MsgStrings = new MsgStr[MAXMSGS];
3870 msg_strings_size = MAXMSGS;
3871 for(auto q = 0; q < msg_strings_size; ++q)
3872 {
3873 MsgStrings[q].clear();
3874 }
3875 }
3876 }
3877
3878 //reset the message strings
3879
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(keepdata)
3880 {
3881
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 init_msgstrings(0,msg_strings_size);
3882 4 }
3883
3884
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t x=0; x<strings_to_read; x++)
3885 {
3886
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 init_msgstr(&tempMsgString);
3887
3888
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!pfread(buf,73,f,true))
3889 {
3890 return qe_invalid;
3891 }
3892
3893 512 buf[74] = '\0';
3894
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 tempMsgString.s = buf;
3895
3896
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f,true))
3897 {
3898 return qe_invalid;
3899 }
3900
3901
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
512 if((Header->zelda_version < 0x192)||
3902 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3903 {
3904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 tempMsgString.nextstring=tempbyte?x+1:0;
3905
3906
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f,true))
3907 {
3908 return qe_invalid;
3909 }
3910
3911
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f,true))
3912 {
3913 return qe_invalid;
3914 }
3915 512 }
3916 else
3917 {
3918 if(!p_igetw(&tempMsgString.nextstring,f,true))
3919 {
3920 return qe_invalid;
3921 }
3922
3923 if(!pfread(temp_expansion,32,f,true))
3924 {
3925 return qe_invalid;
3926 }
3927 }
3928
3929
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(keepdata==true)
3930 {
3931
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 MsgStrings[x] = tempMsgString;
3932 512 }
3933 512 }
3934 4 }
3935 else
3936 {
3937 int32_t dummy_int;
3938 word s_version;
3939 word s_cversion;
3940
3941 //section version info
3942
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&s_version,f,true))
3943 {
3944 return qe_invalid;
3945 }
3946
3947 105 FFCore.quest_format[vStrings] = s_version;
3948
3949
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&s_cversion,f,true))
3950 {
3951 return qe_invalid;
3952 }
3953
3954 //al_trace("Strings version %d\n", s_version);
3955 //section size
3956
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetl(&dummy_int,f,true))
3957 {
3958 return qe_invalid;
3959 }
3960
3961 //finally... section data
3962
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_msg_count,f,true))
3963 {
3964 return qe_invalid;
3965 }
3966
3967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(temp_msg_count >= msg_strings_size)
3968 {
3969 Z_message("Reallocating string buffer...\n");
3970
3971 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3972 // return qe_nomem;
3973 delete[] MsgStrings;
3974 MsgStrings = new MsgStr[MAXMSGS];
3975 msg_strings_size = MAXMSGS;
3976 for(auto q = 0; q < msg_strings_size; ++q)
3977 {
3978 MsgStrings[q].clear();
3979 }
3980 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3981 }
3982
3983 //reset the message strings
3984
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(keepdata)
3985 {
3986
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 25 times.
105 if(s_version < 7)
3987
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3988
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 init_msgstrings(0,msg_strings_size);
3989 105 }
3990
3991 105 int32_t string_length=(s_version<2)?73:145;
3992
3993
2/2
✓ Branch 0 taken 12258 times.
✓ Branch 1 taken 105 times.
12363 for(int32_t i=0; i<temp_msg_count; i++)
3994 {
3995
1/2
✓ Branch 0 taken 12258 times.
✗ Branch 1 not taken.
12258 init_msgstr(&tempMsgString);
3996
2/2
✓ Branch 0 taken 866 times.
✓ Branch 1 taken 11392 times.
12258 if(s_version > 8)
3997 {
3998
2/4
✓ Branch 0 taken 866 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 866 times.
✗ Branch 3 not taken.
866 if(!p_igetl(&string_length,f,true))
3999 {
4000 return qe_invalid;
4001 }
4002 866 }
4003
2/2
✓ Branch 0 taken 12120 times.
✓ Branch 1 taken 138 times.
12258 if (string_length > 0)
4004 {
4005
2/4
✓ Branch 0 taken 12120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12120 times.
✗ Branch 3 not taken.
12120 if (!pfread(buf, string_length, f, true))
4006 {
4007 return qe_invalid;
4008 }
4009 12120 }
4010 else
4011 {
4012 138 buf[0] = 0;
4013 }
4014
4015
2/4
✓ Branch 0 taken 12258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12258 times.
✗ Branch 3 not taken.
12258 if(!p_igetw(&tempMsgString.nextstring,f,true))
4016 {
4017 return qe_invalid;
4018 }
4019
4020
2/2
✓ Branch 0 taken 4646 times.
✓ Branch 1 taken 7612 times.
12258 if(s_version<2)
4021 {
4022 4646 buf[72] = '\0';
4023
1/2
✓ Branch 0 taken 4646 times.
✗ Branch 1 not taken.
4646 tempMsgString.s = buf;
4024 4646 }
4025 else
4026 {
4027 // June 2008: A bug corrupted the last 4 chars of a string.
4028 // Discard these.
4029
1/2
✓ Branch 0 taken 7612 times.
✗ Branch 1 not taken.
7612 if(s_version<3)
4030 {
4031 for(int32_t j=140; j<144; j++)
4032 {
4033 buf[j] = '\0';
4034 }
4035 }
4036
1/2
✓ Branch 0 taken 7612 times.
✗ Branch 1 not taken.
7612 if(string_length > 8192) string_length = 8192;
4037 7612 buf[string_length]='\0'; //Force-terminate
4038
1/2
✓ Branch 0 taken 7612 times.
✗ Branch 1 not taken.
7612 tempMsgString.s = buf;
4039
4040
2/2
✓ Branch 0 taken 866 times.
✓ Branch 1 taken 6746 times.
7612 if ( s_version >= 6 )
4041 {
4042
2/4
✓ Branch 0 taken 866 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 866 times.
✗ Branch 3 not taken.
866 if(!p_igetl(&tempMsgString.tile,f,true))
4043 {
4044 return qe_invalid;
4045 }
4046 866 }
4047 else
4048 {
4049
2/4
✓ Branch 0 taken 6746 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6746 times.
✗ Branch 3 not taken.
6746 if(!p_igetw(&tempMsgString.tile,f,true))
4050 {
4051 return qe_invalid;
4052 }
4053 }
4054
4055
2/4
✓ Branch 0 taken 7612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7612 times.
✗ Branch 3 not taken.
7612 if(!p_getc(&tempMsgString.cset,f,true))
4056 {
4057 return qe_invalid;
4058 }
4059
4060 byte dummy_char;
4061
4062
2/4
✓ Branch 0 taken 7612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7612 times.
✗ Branch 3 not taken.
7612 if(!p_getc(&dummy_char,f,true)) // trans is stored as a char...
4063 {
4064 return qe_invalid;
4065 }
4066
4067 7612 tempMsgString.trans=dummy_char!=0;
4068
4069
2/4
✓ Branch 0 taken 7612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7612 times.
✗ Branch 3 not taken.
7612 if(!p_getc(&tempMsgString.font,f,true))
4070 {
4071 return qe_invalid;
4072 }
4073
4074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7612 times.
7612 if(s_version < 5)
4075 {
4076 if(!p_getc(&tempMsgString.y,f,true))
4077 {
4078 return qe_invalid;
4079 }
4080 }
4081 else
4082 {
4083
2/4
✓ Branch 0 taken 7612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7612 times.
✗ Branch 3 not taken.
7612 if(!p_igetw(&tempMsgString.x,f,true))
4084 {
4085 return qe_invalid;
4086 }
4087
4088
2/4
✓ Branch 0 taken 7612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7612 times.
✗ Branch 3 not taken.
7612 if(!p_igetw(&tempMsgString.y,f,true))
4089 {
4090 return qe_invalid;
4091 }
4092
4093
2/4
✓ Branch 0 taken 7612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7612 times.
✗ Branch 3 not taken.
7612 if(!p_igetw(&tempMsgString.w,f,true))
4094 {
4095 return qe_invalid;
4096 }
4097
4098
2/4
✓ Branch 0 taken 7612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7612 times.
✗ Branch 3 not taken.
7612 if(!p_igetw(&tempMsgString.h,f,true))
4099 {
4100 return qe_invalid;
4101 }
4102
4103
2/4
✓ Branch 0 taken 7612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7612 times.
✗ Branch 3 not taken.
7612 if(!p_getc(&tempMsgString.hspace,f,true))
4104 {
4105 return qe_invalid;
4106 }
4107
4108
2/4
✓ Branch 0 taken 7612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7612 times.
✗ Branch 3 not taken.
7612 if(!p_getc(&tempMsgString.vspace,f,true))
4109 {
4110 return qe_invalid;
4111 }
4112
4113
2/4
✓ Branch 0 taken 7612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7612 times.
✗ Branch 3 not taken.
7612 if(!p_getc(&tempMsgString.stringflags,f,true))
4114 {
4115 return qe_invalid;
4116 }
4117 }
4118
4119
2/2
✓ Branch 0 taken 6746 times.
✓ Branch 1 taken 866 times.
7612 if(s_version >= 7)
4120 {
4121
2/2
✓ Branch 0 taken 866 times.
✓ Branch 1 taken 3464 times.
4330 for(int32_t q = 0; q < 4; ++q)
4122 {
4123
2/4
✓ Branch 0 taken 3464 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3464 times.
✗ Branch 3 not taken.
3464 if(!p_getc(&tempMsgString.margins[q],f,true))
4124 {
4125 return qe_invalid;
4126 }
4127 3464 }
4128
4129
2/4
✓ Branch 0 taken 866 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 866 times.
✗ Branch 3 not taken.
866 if(!p_igetl(&tempMsgString.portrait_tile,f,true))
4130 {
4131 return qe_invalid;
4132 }
4133
4134
2/4
✓ Branch 0 taken 866 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 866 times.
✗ Branch 3 not taken.
866 if(!p_getc(&tempMsgString.portrait_cset,f,true))
4135 {
4136 return qe_invalid;
4137 }
4138
4139
2/4
✓ Branch 0 taken 866 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 866 times.
✗ Branch 3 not taken.
866 if(!p_getc(&tempMsgString.portrait_x,f,true))
4140 {
4141 return qe_invalid;
4142 }
4143
4144
2/4
✓ Branch 0 taken 866 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 866 times.
✗ Branch 3 not taken.
866 if(!p_getc(&tempMsgString.portrait_y,f,true))
4145 {
4146 return qe_invalid;
4147 }
4148
4149
2/4
✓ Branch 0 taken 866 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 866 times.
✗ Branch 3 not taken.
866 if(!p_getc(&tempMsgString.portrait_tw,f,true))
4150 {
4151 return qe_invalid;
4152 }
4153
4154
2/4
✓ Branch 0 taken 866 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 866 times.
✗ Branch 3 not taken.
866 if(!p_getc(&tempMsgString.portrait_th,f,true))
4155 {
4156 return qe_invalid;
4157 }
4158 866 }
4159
4160
2/2
✓ Branch 0 taken 866 times.
✓ Branch 1 taken 6746 times.
7612 if(s_version >= 8)
4161 {
4162
2/4
✓ Branch 0 taken 866 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 866 times.
✗ Branch 3 not taken.
866 if(!p_getc(&tempMsgString.shadow_type,f,true))
4163 {
4164 return qe_invalid;
4165 }
4166
4167
2/4
✓ Branch 0 taken 866 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 866 times.
✗ Branch 3 not taken.
866 if(!p_getc(&tempMsgString.shadow_color,f,true))
4168 {
4169 return qe_invalid;
4170 }
4171 866 }
4172
4173
2/2
✓ Branch 0 taken 749 times.
✓ Branch 1 taken 6863 times.
7612 if(s_version >= 10)
4174 {
4175
2/4
✓ Branch 0 taken 749 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 749 times.
✗ Branch 3 not taken.
749 if(!p_getc(&tempMsgString.drawlayer,f,true))
4176 {
4177 return qe_invalid;
4178 }
4179 749 }
4180
4181
2/4
✓ Branch 0 taken 7612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7612 times.
✗ Branch 3 not taken.
7612 if(!p_getc(&tempMsgString.sfx,f,true))
4182 {
4183 return qe_invalid;
4184 }
4185
4186
1/2
✓ Branch 0 taken 7612 times.
✗ Branch 1 not taken.
7612 if(s_version>3)
4187 {
4188
2/4
✓ Branch 0 taken 7612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7612 times.
✗ Branch 3 not taken.
7612 if(!p_igetw(&tempMsgString.listpos,f,true))
4189 {
4190 return qe_invalid;
4191 }
4192 7612 }
4193 }
4194
4195
1/2
✓ Branch 0 taken 12258 times.
✗ Branch 1 not taken.
12258 if(keepdata==true)
4196 {
4197
1/2
✓ Branch 0 taken 12258 times.
✗ Branch 1 not taken.
12258 MsgStrings[i].copyAll(tempMsgString);
4198 12258 }
4199 12258 }
4200 }
4201
4202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(keepdata==true)
4203 {
4204 109 msg_count=temp_msg_count;
4205 109 }
4206
4207 109 return 0;
4208 109 }
4209
4210 109 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header, bool keepdata)
4211 {
4212
2/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
109 if((Header->zelda_version < 0x192)||
4213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4214 {
4215 4 return 0;
4216 }
4217
4218 105 word temp_door_combo_set_count=0;
4219 DoorComboSet tempDoorComboSet;
4220 word dummy_word;
4221 int32_t dummy_long;
4222 byte padding;
4223 105 int32_t s_version = 0;
4224
4225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(keepdata==true)
4226 {
4227
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 105 times.
26985 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4228 {
4229 26880 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4230 26880 }
4231 105 }
4232
4233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(Header->zelda_version > 0x192)
4234 {
4235 //section version info
4236
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_version,f,true))
4237 {
4238 return qe_invalid;
4239 }
4240
4241 105 FFCore.quest_format[vDoors] = s_version;
4242
4243 //al_trace("Door combo sets version %d\n", dummy_word);
4244
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&dummy_word,f,true))
4245 {
4246 return qe_invalid;
4247 }
4248
4249 //section size
4250
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy_long,f,true))
4251 {
4252 return qe_invalid;
4253 }
4254 105 }
4255
4256 //finally... section data
4257
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&temp_door_combo_set_count,f,true))
4258 {
4259 return qe_invalid;
4260 }
4261
4262
2/2
✓ Branch 0 taken 788 times.
✓ Branch 1 taken 105 times.
893 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4263 {
4264 788 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4265
4266 //name
4267
1/2
✓ Branch 0 taken 788 times.
✗ Branch 1 not taken.
788 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f,true))
4268 {
4269 return qe_invalid;
4270 }
4271
4272
1/2
✓ Branch 0 taken 788 times.
✗ Branch 1 not taken.
788 if(Header->zelda_version < 0x193)
4273 {
4274 if(!p_getc(&padding,f,true))
4275 {
4276 return qe_invalid;
4277 }
4278 }
4279
4280 //up door
4281
2/2
✓ Branch 0 taken 7092 times.
✓ Branch 1 taken 788 times.
7880 for(int32_t j=0; j<9; j++)
4282 {
4283
2/2
✓ Branch 0 taken 28368 times.
✓ Branch 1 taken 7092 times.
35460 for(int32_t k=0; k<4; k++)
4284 {
4285
1/2
✓ Branch 0 taken 28368 times.
✗ Branch 1 not taken.
28368 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f,true))
4286 {
4287 return qe_invalid;
4288 }
4289 28368 }
4290 7092 }
4291
4292
2/2
✓ Branch 0 taken 7092 times.
✓ Branch 1 taken 788 times.
7880 for(int32_t j=0; j<9; j++)
4293 {
4294
2/2
✓ Branch 0 taken 28368 times.
✓ Branch 1 taken 7092 times.
35460 for(int32_t k=0; k<4; k++)
4295 {
4296
1/2
✓ Branch 0 taken 28368 times.
✗ Branch 1 not taken.
28368 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f,true))
4297 {
4298 return qe_invalid;
4299 }
4300 28368 }
4301 7092 }
4302
4303 //down door
4304
2/2
✓ Branch 0 taken 7092 times.
✓ Branch 1 taken 788 times.
7880 for(int32_t j=0; j<9; j++)
4305 {
4306
2/2
✓ Branch 0 taken 28368 times.
✓ Branch 1 taken 7092 times.
35460 for(int32_t k=0; k<4; k++)
4307 {
4308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28368 times.
28368 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f,true))
4309 {
4310 return qe_invalid;
4311 }
4312 28368 }
4313 7092 }
4314
4315
2/2
✓ Branch 0 taken 7092 times.
✓ Branch 1 taken 788 times.
7880 for(int32_t j=0; j<9; j++)
4316 {
4317
2/2
✓ Branch 0 taken 28368 times.
✓ Branch 1 taken 7092 times.
35460 for(int32_t k=0; k<4; k++)
4318 {
4319
1/2
✓ Branch 0 taken 28368 times.
✗ Branch 1 not taken.
28368 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f,true))
4320 {
4321 return qe_invalid;
4322 }
4323 28368 }
4324 7092 }
4325
4326 //left door
4327
2/2
✓ Branch 0 taken 7092 times.
✓ Branch 1 taken 788 times.
7880 for(int32_t j=0; j<9; j++)
4328 {
4329
2/2
✓ Branch 0 taken 42552 times.
✓ Branch 1 taken 7092 times.
49644 for(int32_t k=0; k<6; k++)
4330 {
4331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42552 times.
42552 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f,true))
4332 {
4333 return qe_invalid;
4334 }
4335 42552 }
4336 7092 }
4337
4338
2/2
✓ Branch 0 taken 7092 times.
✓ Branch 1 taken 788 times.
7880 for(int32_t j=0; j<9; j++)
4339 {
4340
2/2
✓ Branch 0 taken 42552 times.
✓ Branch 1 taken 7092 times.
49644 for(int32_t k=0; k<6; k++)
4341 {
4342
1/2
✓ Branch 0 taken 42552 times.
✗ Branch 1 not taken.
42552 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f,true))
4343 {
4344 return qe_invalid;
4345 }
4346 42552 }
4347 7092 }
4348
4349 //right door
4350
2/2
✓ Branch 0 taken 7092 times.
✓ Branch 1 taken 788 times.
7880 for(int32_t j=0; j<9; j++)
4351 {
4352
2/2
✓ Branch 0 taken 42552 times.
✓ Branch 1 taken 7092 times.
49644 for(int32_t k=0; k<6; k++)
4353 {
4354
1/2
✓ Branch 0 taken 42552 times.
✗ Branch 1 not taken.
42552 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f,true))
4355 {
4356 return qe_invalid;
4357 }
4358 42552 }
4359 7092 }
4360
4361
2/2
✓ Branch 0 taken 7092 times.
✓ Branch 1 taken 788 times.
7880 for(int32_t j=0; j<9; j++)
4362 {
4363
2/2
✓ Branch 0 taken 42552 times.
✓ Branch 1 taken 7092 times.
49644 for(int32_t k=0; k<6; k++)
4364 {
4365
1/2
✓ Branch 0 taken 42552 times.
✗ Branch 1 not taken.
42552 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f,true))
4366 {
4367 return qe_invalid;
4368 }
4369 42552 }
4370 7092 }
4371
4372 //up bomb rubble
4373
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 788 times.
2364 for(int32_t j=0; j<2; j++)
4374 {
4375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f,true))
4376 {
4377 return qe_invalid;
4378 }
4379 1576 }
4380
4381
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 788 times.
2364 for(int32_t j=0; j<2; j++)
4382 {
4383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f,true))
4384 {
4385 return qe_invalid;
4386 }
4387 1576 }
4388
4389 //down bomb rubble
4390
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 788 times.
2364 for(int32_t j=0; j<2; j++)
4391 {
4392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f,true))
4393 {
4394 return qe_invalid;
4395 }
4396 1576 }
4397
4398
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 788 times.
2364 for(int32_t j=0; j<2; j++)
4399 {
4400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f,true))
4401 {
4402 return qe_invalid;
4403 }
4404 1576 }
4405
4406 //left bomb rubble
4407
2/2
✓ Branch 0 taken 2364 times.
✓ Branch 1 taken 788 times.
3152 for(int32_t j=0; j<3; j++)
4408 {
4409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2364 times.
2364 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f,true))
4410 {
4411 return qe_invalid;
4412 }
4413 2364 }
4414
4415
2/2
✓ Branch 0 taken 2364 times.
✓ Branch 1 taken 788 times.
3152 for(int32_t j=0; j<3; j++)
4416 {
4417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2364 times.
2364 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f,true))
4418 {
4419 return qe_invalid;
4420 }
4421 2364 }
4422
4423
1/2
✓ Branch 0 taken 788 times.
✗ Branch 1 not taken.
788 if(Header->zelda_version < 0x193)
4424 {
4425 if(!p_getc(&padding,f,true))
4426 {
4427 return qe_invalid;
4428 }
4429
4430 }
4431
4432 //right bomb rubble
4433
2/2
✓ Branch 0 taken 2364 times.
✓ Branch 1 taken 788 times.
3152 for(int32_t j=0; j<3; j++)
4434 {
4435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2364 times.
2364 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f,true))
4436 {
4437 return qe_invalid;
4438 }
4439 2364 }
4440
4441
2/2
✓ Branch 0 taken 2364 times.
✓ Branch 1 taken 788 times.
3152 for(int32_t j=0; j<3; j++)
4442 {
4443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2364 times.
2364 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f,true))
4444 {
4445 return qe_invalid;
4446 }
4447 2364 }
4448
4449
1/2
✓ Branch 0 taken 788 times.
✗ Branch 1 not taken.
788 if(Header->zelda_version < 0x193)
4450 {
4451 if(!p_getc(&padding,f,true))
4452 {
4453 return qe_invalid;
4454 }
4455 }
4456
4457 //walkthrough stuff
4458
2/2
✓ Branch 0 taken 3152 times.
✓ Branch 1 taken 788 times.
3940 for(int32_t j=0; j<4; j++)
4459 {
4460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3152 times.
3152 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f,true))
4461 {
4462 return qe_invalid;
4463 }
4464 3152 }
4465
4466
2/2
✓ Branch 0 taken 3152 times.
✓ Branch 1 taken 788 times.
3940 for(int32_t j=0; j<4; j++)
4467 {
4468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3152 times.
3152 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f,true))
4469 {
4470 return qe_invalid;
4471 }
4472 3152 }
4473
4474 //flags
4475
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 788 times.
2364 for(int32_t j=0; j<2; j++)
4476 {
4477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1576 times.
1576 if(!p_getc(&tempDoorComboSet.flags[j],f,true))
4478 {
4479 return qe_invalid;
4480 }
4481 1576 }
4482
4483
1/2
✓ Branch 0 taken 788 times.
✗ Branch 1 not taken.
788 if(Header->zelda_version < 0x193)
4484 {
4485 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f,true))
4486 {
4487 return qe_invalid;
4488 }
4489 }
4490
4491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 788 times.
788 if(keepdata==true)
4492 {
4493 788 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4494 788 }
4495 788 }
4496
4497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(keepdata==true)
4498 {
4499 105 door_combo_set_count=temp_door_combo_set_count;
4500 105 }
4501
4502 105 return 0;
4503 109 }
4504
4505 int32_t count_dmaps()
4506 {
4507 int32_t i=MAXDMAPS-1;
4508 bool found=false;
4509
4510 while(i>=0 && !found)
4511 {
4512 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4513 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4514 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4515 found=true;
4516
4517 for(int32_t j=0; j<8; j++)
4518 {
4519 if(DMaps[i].grid[j]!=0)
4520
4521 found=true;
4522 }
4523
4524 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4525 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4526 found=true;
4527
4528 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4529 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4530 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4531 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4532 found=true;
4533
4534 if(!found)
4535 {
4536 i--;
4537 }
4538 }
4539
4540 return i+1;
4541 }
4542
4543
4544 int32_t count_shops(miscQdata *Misc)
4545 {
4546 int32_t i=255,j;
4547 bool found=false;
4548
4549 while(i>=0 && !found)
4550 {
4551 j=2;
4552
4553 while(j>=0 && !found)
4554 {
4555 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4556 {
4557 found=true;
4558 }
4559 else
4560 {
4561 j--;
4562 }
4563 }
4564
4565 if(Misc->shop[i].name[0]!=0)
4566 {
4567 found=true;
4568 }
4569
4570 if(!found)
4571 {
4572 i--;
4573 }
4574 }
4575
4576 return i+1;
4577 }
4578
4579 int32_t count_infos(miscQdata *Misc)
4580 {
4581 int32_t i=255,j;
4582 bool found=false;
4583
4584 while(i>=0 && !found)
4585 {
4586 j=2;
4587
4588 while(j>=0 && !found)
4589 {
4590 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4591 {
4592 found=true;
4593 }
4594 else
4595 {
4596 j--;
4597 }
4598 }
4599
4600 if(Misc->info[i].name[0]!=0)
4601 {
4602 found=true;
4603 }
4604
4605 if(!found)
4606 {
4607 i--;
4608 }
4609 }
4610
4611 return i+1;
4612 }
4613
4614 int32_t count_warprings(miscQdata *Misc)
4615 {
4616 int32_t i=15,j;
4617 bool found=false;
4618
4619 while(i>=0 && !found)
4620 {
4621 j=7;
4622
4623 while(j>=0 && !found)
4624 {
4625 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4626 {
4627 found=true;
4628 }
4629 else
4630 {
4631 j--;
4632 }
4633 }
4634
4635 if(!found)
4636 {
4637 i--;
4638 }
4639 }
4640
4641 return i+1;
4642 }
4643
4644 int32_t count_palcycles(miscQdata *Misc)
4645 {
4646 int32_t i=255,j;
4647 bool found=false;
4648
4649 while(i>=0 && !found)
4650 {
4651 j=2;
4652
4653 while(j>=0 && !found)
4654 {
4655 if(Misc->cycles[i][j].count!=0)
4656 {
4657 found=true;
4658 }
4659 else
4660 {
4661 j--;
4662 }
4663 }
4664
4665 if(!found)
4666 {
4667 i--;
4668 }
4669 }
4670
4671 return i+1;
4672 }
4673
4674 200229 void clear_screen(mapscr *temp_scr)
4675 {
4676 200229 temp_scr->zero_memory();
4677 200229 }
4678
4679 109 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps, bool keepdata)
4680 {
4681 109 word dmapstoread=0;
4682 dmap tempDMap;
4683
4684 int32_t dummy;
4685 109 word s_version=0, s_cversion=0;
4686 byte padding;
4687
4688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(keepdata==true)
4689 {
4690
2/2
✓ Branch 0 taken 55808 times.
✓ Branch 1 taken 109 times.
55917 for(int32_t i=0; i<max_dmaps; i++)
4691 {
4692 55808 memset(&DMaps[start_dmap+i],0,sizeof(dmap));
4693 55808 sprintf(DMaps[start_dmap+i].title," ");
4694 55808 sprintf(DMaps[start_dmap+i].intro," ");
4695 55808 DMaps[start_dmap+i].type |= dmCAVE;
4696 55808 }
4697 109 }
4698
4699
3/4
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✓ Branch 3 taken 4 times.
109 if(!Header || Header->zelda_version > 0x192)
4700 {
4701 //section version info
4702
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_version,f,true))
4703 {
4704 return qe_invalid;
4705 }
4706
4707 105 FFCore.quest_format[vDMaps] = s_version;
4708
4709 //al_trace("DMaps version %d\n", s_version);
4710
4711
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_cversion,f,true))
4712 {
4713 return qe_invalid;
4714 }
4715
4716 //section size
4717
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy,f,true))
4718 {
4719 return qe_invalid;
4720 }
4721
4722 //finally... section data
4723
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&dmapstoread,f,true))
4724 {
4725 return qe_invalid;
4726 }
4727 105 }
4728 else
4729 {
4730
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
4731 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4732 {
4733 4 dmapstoread=32;
4734 4 }
4735 else if(s_version <= 4)
4736 {
4737 dmapstoread=OLDMAXDMAPS;
4738 }
4739 else
4740 {
4741 dmapstoread=MAXDMAPS;
4742 }
4743 }
4744
4745
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 100 times.
109 dmapstoread=zc_min(dmapstoread, max_dmaps);
4746
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 100 times.
109 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4747
4748
2/2
✓ Branch 0 taken 52608 times.
✓ Branch 1 taken 109 times.
52717 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4749 {
4750 52608 memset(&tempDMap,0,sizeof(dmap));
4751 52608 sprintf(tempDMap.title," ");
4752 52608 sprintf(tempDMap.intro," ");
4753
4754
1/2
✓ Branch 0 taken 52608 times.
✗ Branch 1 not taken.
52608 if(!p_getc(&tempDMap.map,f,keepdata))
4755 {
4756 return qe_invalid;
4757 }
4758
4759
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 51200 times.
52608 if(s_version <= 4)
4760 {
4761 byte tempbyte;
4762
4763
1/2
✓ Branch 0 taken 1408 times.
✗ Branch 1 not taken.
1408 if(!p_getc(&tempbyte,f,keepdata))
4764 {
4765 return qe_invalid;
4766 }
4767
4768 1408 tempDMap.level=(word)tempbyte;
4769 1408 }
4770 else
4771 {
4772
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&tempDMap.level,f,keepdata))
4773 {
4774 return qe_invalid;
4775 }
4776 }
4777
4778
1/2
✓ Branch 0 taken 52608 times.
✗ Branch 1 not taken.
52608 if(!p_getc(&tempDMap.xoff,f,keepdata))
4779 {
4780 return qe_invalid;
4781 }
4782
4783
1/2
✓ Branch 0 taken 52608 times.
✗ Branch 1 not taken.
52608 if(!p_getc(&tempDMap.compass,f,keepdata))
4784 {
4785 return qe_invalid;
4786 }
4787
4788
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 1408 times.
52608 if(s_version > 8) // February 2009
4789 {
4790
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&tempDMap.color,f,true))
4791 {
4792 return qe_invalid;
4793 }
4794 51200 }
4795 else
4796 {
4797 byte tempbyte;
4798
4799
1/2
✓ Branch 0 taken 1408 times.
✗ Branch 1 not taken.
1408 if(!p_getc(&tempbyte,f,true))
4800 {
4801 return qe_invalid;
4802 }
4803
4804 1408 tempDMap.color = (word)tempbyte;
4805 }
4806
4807
1/2
✓ Branch 0 taken 52608 times.
✗ Branch 1 not taken.
52608 if(!p_getc(&tempDMap.midi,f,keepdata))
4808 {
4809 return qe_invalid;
4810 }
4811
4812
1/2
✓ Branch 0 taken 52608 times.
✗ Branch 1 not taken.
52608 if(!p_getc(&tempDMap.cont,f,keepdata))
4813 {
4814 return qe_invalid;
4815 }
4816
4817
1/2
✓ Branch 0 taken 52608 times.
✗ Branch 1 not taken.
52608 if(!p_getc(&tempDMap.type,f,keepdata))
4818 {
4819 return qe_invalid;
4820 }
4821
4822
4/4
✓ Branch 0 taken 653 times.
✓ Branch 1 taken 51955 times.
✓ Branch 2 taken 641 times.
✓ Branch 3 taken 12 times.
53261 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4823
1/2
✓ Branch 0 taken 653 times.
✗ Branch 1 not taken.
653 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4824 641 tempDMap.xoff = 0;
4825
4826
2/2
✓ Branch 0 taken 420864 times.
✓ Branch 1 taken 52608 times.
473472 for(int32_t j=0; j<8; j++)
4827 {
4828
1/2
✓ Branch 0 taken 420864 times.
✗ Branch 1 not taken.
420864 if(!p_getc(&tempDMap.grid[j],f,keepdata))
4829 {
4830 return qe_invalid;
4831 }
4832 420864 }
4833
4834
4/8
✓ Branch 0 taken 52608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52480 times.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 52480 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
52608 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4835 {
4836
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
128 if(tempDMap.level>0&&tempDMap.level<10)
4837 {
4838 38 sprintf(tempDMap.title,"LEVEL-%d ", tempDMap.level);
4839 38 }
4840
4841
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
128 if(i==0 && Header->zelda_version <= 0x190)
4842 {
4843 4 tempDMap.cont-=tempDMap.xoff;
4844 4 tempDMap.compass-=tempDMap.xoff;
4845 4 }
4846
4847 //forgotten -DD
4848
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
128 if(tempDMap.level==0)
4849 {
4850 90 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4851 90 }
4852 128 }
4853 else
4854 {
4855
1/2
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
52480 if(!pfread(&tempDMap.name,sizeof(DMaps[0].name),f,true))
4856 {
4857 return qe_invalid;
4858 }
4859
4860
1/2
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
52480 if(!pfread(&tempDMap.title,sizeof(DMaps[0].title),f,true))
4861 {
4862 return qe_invalid;
4863 }
4864
4865
1/2
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
52480 if(!pfread(&tempDMap.intro,sizeof(DMaps[0].intro),f,true))
4866 {
4867 return qe_invalid;
4868 }
4869
4870
3/8
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52480 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 52480 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
52480 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4871 {
4872 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4873 if(keepdata==true)
4874 {
4875 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
4876 }
4877
4878 continue;
4879 }
4880
4881
2/4
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52480 times.
✗ Branch 3 not taken.
52480 if(Header && (Header->zelda_version < 0x193))
4882 {
4883 if(!p_getc(&padding,f,keepdata))
4884 {
4885 return qe_invalid;
4886 }
4887 }
4888
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 39680 times.
52480 if ( s_version >= 11 )
4889 {
4890
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&tempDMap.minimap_1_tile,f,keepdata))
4891 {
4892 return qe_invalid;
4893 }
4894 12800 }
4895 else
4896 {
4897
1/2
✓ Branch 0 taken 39680 times.
✗ Branch 1 not taken.
39680 if(!p_igetw(&tempDMap.minimap_1_tile,f,keepdata))
4898 {
4899 return qe_invalid;
4900 }
4901 }
4902
4903
1/2
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
52480 if(!p_getc(&tempDMap.minimap_1_cset,f,keepdata))
4904 {
4905 return qe_invalid;
4906 }
4907
4908
2/4
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52480 times.
✗ Branch 3 not taken.
52480 if(Header && (Header->zelda_version < 0x193))
4909 {
4910 if(!p_getc(&padding,f,keepdata))
4911 {
4912 return qe_invalid;
4913 }
4914 }
4915
4916
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 39680 times.
52480 if ( s_version >= 11 )
4917 {
4918
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&tempDMap.minimap_2_tile,f,keepdata))
4919 {
4920 return qe_invalid;
4921 }
4922 12800 }
4923 else
4924 {
4925
1/2
✓ Branch 0 taken 39680 times.
✗ Branch 1 not taken.
39680 if(!p_igetw(&tempDMap.minimap_2_tile,f,keepdata))
4926 {
4927 return qe_invalid;
4928 }
4929 }
4930
1/2
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
52480 if(!p_getc(&tempDMap.minimap_2_cset,f,keepdata))
4931 {
4932 return qe_invalid;
4933 }
4934
4935
2/4
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52480 times.
✗ Branch 3 not taken.
52480 if(Header && (Header->zelda_version < 0x193))
4936 {
4937 if(!p_getc(&padding,f,keepdata))
4938 {
4939 return qe_invalid;
4940 }
4941 }
4942
4943
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 39680 times.
52480 if ( s_version >= 11 )
4944 {
4945
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&tempDMap.largemap_1_tile,f,keepdata))
4946 {
4947 return qe_invalid;
4948 }
4949 12800 }
4950 else
4951 {
4952
1/2
✓ Branch 0 taken 39680 times.
✗ Branch 1 not taken.
39680 if(!p_igetw(&tempDMap.largemap_1_tile,f,keepdata))
4953 {
4954 return qe_invalid;
4955 }
4956 }
4957
4958
1/2
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
52480 if(!p_getc(&tempDMap.largemap_1_cset,f,keepdata))
4959 {
4960 return qe_invalid;
4961 }
4962
4963
2/4
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52480 times.
✗ Branch 3 not taken.
52480 if(Header && (Header->zelda_version < 0x193))
4964 {
4965
4966 if(!p_getc(&padding,f,keepdata))
4967 {
4968 return qe_invalid;
4969 }
4970 }
4971
4972
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 39680 times.
52480 if ( s_version >= 11 )
4973 {
4974
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&tempDMap.largemap_2_tile,f,keepdata))
4975 {
4976 return qe_invalid;
4977 }
4978 12800 }
4979 else
4980 {
4981
1/2
✓ Branch 0 taken 39680 times.
✗ Branch 1 not taken.
39680 if(!p_igetw(&tempDMap.largemap_2_tile,f,keepdata))
4982 {
4983 return qe_invalid;
4984 }
4985 }
4986
1/2
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
52480 if(!p_getc(&tempDMap.largemap_2_cset,f,keepdata))
4987 {
4988 return qe_invalid;
4989 }
4990
4991
1/2
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
52480 if(!pfread(&tempDMap.tmusic,sizeof(DMaps[0].tmusic),f,true))
4992 {
4993 return qe_invalid;
4994 }
4995 }
4996
4997
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 51200 times.
52608 if(s_version>1)
4998 {
4999
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_getc(&tempDMap.tmusictrack,f,keepdata))
5000 {
5001 return qe_invalid;
5002 }
5003
5004
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_getc(&tempDMap.active_subscreen,f,keepdata))
5005 {
5006 return qe_invalid;
5007 }
5008
5009
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_getc(&tempDMap.passive_subscreen,f,keepdata))
5010 {
5011 return qe_invalid;
5012 }
5013 51200 }
5014
5015
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 51200 times.
52608 if(s_version>2)
5016 {
5017 byte di[32];
5018
5019
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!pfread(&di, 32, f, true)) return qe_invalid;
5020
5021
2/2
✓ Branch 0 taken 13107200 times.
✓ Branch 1 taken 51200 times.
13158400 for(int32_t j=0; j<MAXITEMS; j++)
5022 {
5023
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13107193 times.
13107200 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
5024 13107193 else tempDMap.disableditems[j]=0;
5025 13107200 }
5026 51200 }
5027
5028
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 1408 times.
52608 if(s_version >= 6)
5029 {
5030
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetl(&tempDMap.flags,f,keepdata))
5031 {
5032 return qe_invalid;
5033 }
5034 51200 }
5035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1408 times.
1408 else if(s_version>3)
5036 {
5037 char temp;
5038
5039 if(!p_getc(&temp,f,keepdata))
5040 {
5041 return qe_invalid;
5042 }
5043
5044 tempDMap.flags = temp;
5045 }
5046
3/8
✓ Branch 0 taken 697 times.
✓ Branch 1 taken 711 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 697 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1408 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
5047 {
5048 697 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
5049 697 }
5050 else
5051 711 tempDMap.flags=0;
5052
5053
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 1408 times.
52608 if(s_version<7)
5054 {
5055
3/4
✓ Branch 0 taken 697 times.
✓ Branch 1 taken 711 times.
✓ Branch 2 taken 697 times.
✗ Branch 3 not taken.
1408 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
5056 697 tempDMap.flags|= dmfVIEWMAP;
5057 1408 }
5058
5059
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 1408 times.
52608 if(s_version<8)
5060 {
5061
4/4
✓ Branch 0 taken 697 times.
✓ Branch 1 taken 711 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 609 times.
1408 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
5062 {
5063 609 tempDMap.type &= ~dmDNGN;
5064 609 tempDMap.type |= dmCAVE;
5065 609 }
5066
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 469 times.
799 else if((tempDMap.type&dmfTYPE)==dmCAVE)
5067 {
5068 469 tempDMap.flags |= dmfMINIMAPCOLORFIX;
5069 469 }
5070 1408 }
5071
5072
5/8
✓ Branch 0 taken 52608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 52480 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 128 times.
✓ Branch 6 taken 52480 times.
✗ Branch 7 not taken.
52608 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
5073 52480 && (Header->zelda_version < 0x193))
5074 {
5075 if(!p_getc(&padding,f,keepdata))
5076 {
5077 return qe_invalid;
5078 }
5079 }
5080
5081
2/2
✓ Branch 0 taken 39808 times.
✓ Branch 1 taken 12800 times.
52608 if(s_version >= 10)
5082 {
5083
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&tempDMap.sideview,f,keepdata))
5084 {
5085 return qe_invalid;
5086 }
5087 12800 }
5088
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 39808 times.
52608 if(s_version < 10) tempDMap.sideview = 0;
5089
5090 //Dmap Scripts
5091
2/2
✓ Branch 0 taken 39808 times.
✓ Branch 1 taken 12800 times.
52608 if(s_version >= 12)
5092 {
5093
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&tempDMap.script,f,keepdata))
5094 {
5095 return qe_invalid;
5096 }
5097
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 12800 times.
115200 for ( int32_t q = 0; q < 8; q++ )
5098 {
5099
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_igetl(&tempDMap.initD[q],f,keepdata))
5100 {
5101 return qe_invalid;
5102 }
5103 102400 }
5104 12800 }
5105
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 39808 times.
52608 if ( s_version < 12 )
5106 {
5107 39808 tempDMap.script = 0;
5108
2/2
✓ Branch 0 taken 318464 times.
✓ Branch 1 taken 39808 times.
358272 for ( int32_t q = 0; q < 8; q++ )
5109 {
5110 318464 tempDMap.initD[q] = 0;
5111 318464 }
5112 39808 }
5113
5114
2/2
✓ Branch 0 taken 39808 times.
✓ Branch 1 taken 12800 times.
52608 if(s_version >= 13)
5115 {
5116
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 12800 times.
115200 for ( int32_t q = 0; q < 8; q++ )
5117 {
5118
2/2
✓ Branch 0 taken 6656000 times.
✓ Branch 1 taken 102400 times.
6758400 for ( int32_t w = 0; w < 65; w++ )
5119 {
5120
1/2
✓ Branch 0 taken 6656000 times.
✗ Branch 1 not taken.
6656000 if(!p_getc(&tempDMap.initD_label[q][w],f,keepdata))
5121 {
5122 return qe_invalid;
5123 }
5124 6656000 }
5125 102400 }
5126 12800 }
5127
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 39808 times.
52608 if ( s_version < 13 )
5128 {
5129 39808 tempDMap.script = 0;
5130
2/2
✓ Branch 0 taken 318464 times.
✓ Branch 1 taken 39808 times.
358272 for ( int32_t q = 0; q < 8; q++ )
5131 {
5132
2/2
✓ Branch 0 taken 20700160 times.
✓ Branch 1 taken 318464 times.
21018624 for ( int32_t w = 0; w < 65; w++ )
5133 20700160 tempDMap.initD_label[q][w] = 0;
5134 318464 }
5135 39808 }
5136
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 39808 times.
52608 if(s_version >= 14)
5137 {
5138
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&tempDMap.active_sub_script,f,keepdata))
5139 {
5140 return qe_invalid;
5141 }
5142
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&tempDMap.passive_sub_script,f,keepdata))
5143 {
5144 return qe_invalid;
5145 }
5146
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 12800 times.
115200 for ( int32_t q = 0; q < 8; ++q )
5147 {
5148
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_igetl(&tempDMap.sub_initD[q],f,keepdata))
5149 {
5150 return qe_invalid;
5151 }
5152 102400 }
5153
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 12800 times.
115200 for(int32_t q = 0; q < 8; ++q)
5154 {
5155
2/2
✓ Branch 0 taken 6656000 times.
✓ Branch 1 taken 102400 times.
6758400 for ( int32_t w = 0; w < 65; ++w )
5156 {
5157
1/2
✓ Branch 0 taken 6656000 times.
✗ Branch 1 not taken.
6656000 if(!p_getc(&tempDMap.sub_initD_label[q][w],f,keepdata))
5158 {
5159 return qe_invalid;
5160 }
5161 6656000 }
5162 102400 }
5163 12800 }
5164 else
5165 {
5166 39808 tempDMap.active_sub_script = 0;
5167 39808 tempDMap.passive_sub_script = 0;
5168
2/2
✓ Branch 0 taken 318464 times.
✓ Branch 1 taken 39808 times.
358272 for(int32_t q = 0; q < 8; ++q)
5169 {
5170 318464 tempDMap.sub_initD[q] = 0;
5171
2/2
✓ Branch 0 taken 20700160 times.
✓ Branch 1 taken 318464 times.
21018624 for(int32_t w = 0; w < 65; ++w)
5172 20700160 tempDMap.sub_initD_label[q][w] = 0;
5173 318464 }
5174 }
5175
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 39808 times.
52608 if(s_version >= 15)
5176 {
5177
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&tempDMap.onmap_script,f,keepdata))
5178 {
5179 return qe_invalid;
5180 }
5181
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 12800 times.
115200 for ( int32_t q = 0; q < 8; ++q )
5182 {
5183
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_igetl(&tempDMap.onmap_initD[q],f,keepdata))
5184 {
5185 return qe_invalid;
5186 }
5187 102400 }
5188
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 12800 times.
115200 for(int32_t q = 0; q < 8; ++q)
5189 {
5190
2/2
✓ Branch 0 taken 6656000 times.
✓ Branch 1 taken 102400 times.
6758400 for ( int32_t w = 0; w < 65; ++w )
5191 {
5192
1/2
✓ Branch 0 taken 6656000 times.
✗ Branch 1 not taken.
6656000 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f,keepdata))
5193 {
5194 return qe_invalid;
5195 }
5196 6656000 }
5197 102400 }
5198 12800 }
5199 else
5200 {
5201 39808 tempDMap.onmap_script = 0;
5202
2/2
✓ Branch 0 taken 318464 times.
✓ Branch 1 taken 39808 times.
358272 for(int32_t q = 0; q < 8; ++q)
5203 {
5204 318464 tempDMap.onmap_initD[q] = 0;
5205
2/2
✓ Branch 0 taken 20700160 times.
✓ Branch 1 taken 318464 times.
21018624 for(int32_t w = 0; w < 65; ++w)
5206 {
5207 20700160 tempDMap.onmap_initD_label[q][w] = 0;
5208 20700160 }
5209 318464 }
5210 }
5211
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 39808 times.
52608 if(s_version >= 16)
5212 {
5213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12800 times.
12800 if(!p_igetw(&tempDMap.mirrorDMap,f,keepdata))
5214 {
5215 return qe_invalid;
5216 }
5217 12800 }
5218 else
5219 {
5220 39808 tempDMap.mirrorDMap = -1;
5221 }
5222
5223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52608 times.
52608 if(keepdata==true)
5224 {
5225 52608 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
5226 52608 }
5227 52608 }
5228
5229 109 return 0;
5230 109 }
5231
5232 100 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5233 {
5234 //these are here to bypass compiler warnings about unused arguments
5235 100 Header=Header;
5236
5237 miscQdata temp_misc;
5238 100 word s_version=0, s_cversion=0;
5239 100 int32_t tempsize=0;
5240 word dummyw;
5241
5242 100 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5243
5244 //section version info
5245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_igetw(&s_version,f,true))
5246 {
5247 return qe_invalid;
5248 }
5249
5250 100 FFCore.quest_format[vColours] = s_version;
5251
5252 100 al_trace("Misc Colours section version: %d\n", s_version);
5253
5254 //al_trace("Misc. colors version %d\n", s_version);
5255
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetw(&s_cversion,f,true))
5256 {
5257 return qe_invalid;
5258 }
5259
5260
5261 //section size
5262
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tempsize,f,true))
5263 {
5264 return qe_invalid;
5265 }
5266
5267 //finally... section data
5268 100 readsize=0;
5269
5270
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_misc.colors.text,f,true))
5271 {
5272 return qe_invalid;
5273 }
5274
5275
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_misc.colors.caption,f,true))
5276 {
5277 return qe_invalid;
5278 }
5279
5280
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5281 {
5282 return qe_invalid;
5283 }
5284
5285
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5286 {
5287 return qe_invalid;
5288 }
5289
5290
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5291 {
5292 return qe_invalid;
5293 }
5294
5295
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5296 {
5297 return qe_invalid;
5298 }
5299
5300
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5301 {
5302 return qe_invalid;
5303 }
5304
5305
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5306 {
5307 return qe_invalid;
5308 }
5309
5310
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5311 {
5312 return qe_invalid;
5313 }
5314
5315
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5316 {
5317 return qe_invalid;
5318 }
5319
5320
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5321 {
5322 return qe_invalid;
5323 }
5324
5325
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5326 {
5327 return qe_invalid;
5328 }
5329
5330
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5331 {
5332 return qe_invalid;
5333 }
5334
5335
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5336 {
5337 return qe_invalid;
5338 }
5339
5340
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5341 {
5342 return qe_invalid;
5343 }
5344
5345
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5346 {
5347 return qe_invalid;
5348 }
5349
5350
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5351 {
5352 return qe_invalid;
5353 }
5354
5355
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5356 {
5357 return qe_invalid;
5358 }
5359
5360
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5361 {
5362 return qe_invalid;
5363 }
5364
5365
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
5366 {
5367 return qe_invalid;
5368 }
5369
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 75 times.
100 if(s_version < 4)
5370 {
5371
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetw(&dummyw,f,true))
5372 return qe_invalid;
5373 75 temp_misc.colors.triforce_tile = dummyw;
5374
5375
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetw(&dummyw,f,true))
5376 return qe_invalid;
5377 75 temp_misc.colors.triframe_tile = dummyw;
5378
5379
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetw(&dummyw,f,true))
5380 return qe_invalid;
5381 75 temp_misc.colors.overworld_map_tile = dummyw;
5382
5383
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetw(&dummyw,f,true))
5384 return qe_invalid;
5385 75 temp_misc.colors.dungeon_map_tile = dummyw;
5386
5387
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetw(&dummyw,f,true))
5388 return qe_invalid;
5389 75 temp_misc.colors.blueframe_tile = dummyw;
5390
5391
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetw(&dummyw,f,true))
5392 return qe_invalid;
5393 75 temp_misc.colors.HCpieces_tile = dummyw;
5394 75 }
5395
5396
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
5397 {
5398 return qe_invalid;
5399 }
5400
5401
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
5402 {
5403 return qe_invalid;
5404 }
5405
5406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(s_version < 2)
5407 {
5408 temp_misc.colors.msgtext = 0x01;
5409 }
5410 else
5411 {
5412
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&temp_misc.colors.msgtext, f, true))
5413 {
5414 return qe_invalid;
5415 }
5416 }
5417
5418
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 25 times.
100 if ( s_version >= 3 ) //expanded tile pages to 825
5419 {
5420
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&temp_misc.colors.triforce_tile,f,true))
5421 {
5422 return qe_invalid;
5423 }
5424
5425
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&temp_misc.colors.triframe_tile,f,true))
5426 {
5427 return qe_invalid;
5428 }
5429
5430
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f,true))
5431 {
5432 return qe_invalid;
5433 }
5434
5435
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f,true))
5436 {
5437 return qe_invalid;
5438 }
5439
5440
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&temp_misc.colors.blueframe_tile,f,true))
5441 {
5442 return qe_invalid;
5443 }
5444
5445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f,true))
5446 {
5447 return qe_invalid;
5448 }
5449 25 }
5450
5451
5452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata==true)
5453 {
5454 100 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5455 100 }
5456
5457 100 return 0;
5458 100 }
5459
5460 100 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc, bool keepdata)
5461 {
5462 miscQdata temp_misc;
5463 100 word s_version=0, s_cversion=0;
5464 byte icons;
5465 100 int32_t tempsize=0;
5466
5467 100 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5468
5469 //section version info
5470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_igetw(&s_version,f,true))
5471 {
5472 return qe_invalid;
5473 }
5474
5475 100 FFCore.quest_format[vIcons] = s_version;
5476
5477 //al_trace("Game icons version %d\n", s_version);
5478
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetw(&s_cversion,f,true))
5479 {
5480 return qe_invalid;
5481 }
5482
5483
5484 //section size
5485
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tempsize,f,true))
5486 {
5487 return qe_invalid;
5488 }
5489
5490 //finally... section data
5491 100 readsize=0;
5492
5493 100 icons=4;
5494
5495
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 75 times.
100 if ( s_version >= 10 )
5496 {
5497
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t i=0; i<icons; i++)
5498 {
5499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_igetl(&temp_misc.icons[i],f,true))
5500 {
5501 return qe_invalid;
5502 }
5503 100 }
5504 25 }
5505 else
5506 {
5507
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 75 times.
375 for(int32_t i=0; i<icons; i++)
5508 {
5509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300 times.
300 if(!p_igetw(&temp_misc.icons[i],f,true))
5510 {
5511 return qe_invalid;
5512 }
5513 300 }
5514 }
5515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata==true)
5516 {
5517 100 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5518 100 }
5519
5520 100 return 0;
5521 100 }
5522
5523 109 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5524 {
5525 109 word maxinfos=256;
5526 109 word maxshops=256;
5527 109 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5528 109 word ponds=16, pondsize=72, expansionsize=98*2;
5529 byte tempbyte, padding;
5530 miscQdata temp_misc;
5531 109 word s_version=0, s_cversion=0;
5532 word swaptmp;
5533 109 int32_t tempsize=0;
5534
5535 109 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5536
5537
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<maxshops; ++i)
5538 {
5539 27904 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5540 27904 }
5541
5542
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<maxinfos; ++i)
5543 {
5544 27904 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5545 27904 }
5546
5547
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 105 times.
109 if(Header->zelda_version > 0x192)
5548 {
5549 //section version info
5550
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_version,f,true))
5551 {
5552 return qe_invalid;
5553 }
5554
5555 105 FFCore.quest_format[vMisc] = s_version;
5556
5557 //al_trace("Misc. data version %d\n", s_version);
5558
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_cversion,f,true))
5559 {
5560 return qe_invalid;
5561 }
5562
5563
5564 //section size
5565
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&tempsize,f,true))
5566 {
5567 return qe_invalid;
5568 }
5569 105 }
5570
5571 //finally... section data
5572 109 readsize=0;
5573
5574 //shops
5575
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 105 times.
109 if(Header->zelda_version > 0x192)
5576 {
5577
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&shops,f,true))
5578 {
5579 return qe_invalid;
5580 }
5581 105 }
5582
5583
2/2
✓ Branch 0 taken 1159 times.
✓ Branch 1 taken 109 times.
1268 for(int32_t i=0; i<shops; i++)
5584 {
5585
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 1041 times.
1159 if(s_version > 6)
5586 {
5587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1041 times.
1041 if(!pfread(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name),f,true))
5588 {
5589 return qe_invalid;
5590 }
5591 1041 }
5592
5593
2/2
✓ Branch 0 taken 3477 times.
✓ Branch 1 taken 1159 times.
4636 for(int32_t j=0; j<3; j++)
5594 {
5595
1/2
✓ Branch 0 taken 3477 times.
✗ Branch 1 not taken.
3477 if(!p_getc(&temp_misc.shop[i].item[j],f,true))
5596 {
5597 return qe_invalid;
5598 }
5599
5600
2/2
✓ Branch 0 taken 3123 times.
✓ Branch 1 taken 354 times.
3477 if(s_version < 4)
5601 {
5602 354 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5603 354 }
5604 3477 }
5605
5606
2/2
✓ Branch 0 taken 1095 times.
✓ Branch 1 taken 64 times.
1159 if(Header->zelda_version < 0x193)
5607 {
5608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(!p_getc(&tempbyte,f,true))
5609 {
5610 return qe_invalid;
5611 }
5612 64 }
5613
5614
2/2
✓ Branch 0 taken 3477 times.
✓ Branch 1 taken 1159 times.
4636 for(int32_t j=0; j<3; j++)
5615 {
5616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3477 times.
3477 if(!p_igetw(&temp_misc.shop[i].price[j],f,true))
5617 {
5618 return qe_invalid;
5619 }
5620 3477 }
5621
5622
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 1041 times.
1159 if(s_version > 3)
5623 {
5624
2/2
✓ Branch 0 taken 3123 times.
✓ Branch 1 taken 1041 times.
4164 for(int32_t j=0; j<3; j++)
5625 {
5626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3123 times.
3123 if(!p_getc(&temp_misc.shop[i].hasitem[j],f,true))
5627 return qe_invalid;
5628 3123 }
5629 1041 }
5630
5631 /*
5632 if(s_version < 8)
5633 {
5634 for(int32_t j=0; j<3; j++)
5635 {
5636 (&temp_misc.shop[i].str[j])=0; //initialise.
5637 }
5638 }
5639 */
5640 1159 }
5641
5642 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5643
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<maxshops; ++i)
5644 {
5645
2/2
✓ Branch 0 taken 55808 times.
✓ Branch 1 taken 27904 times.
83712 for(int32_t j=0; j<3-1; j++)
5646 {
5647
2/2
✓ Branch 0 taken 83712 times.
✓ Branch 1 taken 55808 times.
139520 for(int32_t k=0; k<2-j; k++)
5648 {
5649
2/2
✓ Branch 0 taken 2444 times.
✓ Branch 1 taken 81268 times.
83712 if(temp_misc.shop[i].hasitem[k]==0)
5650 {
5651 81268 swaptmp = temp_misc.shop[i].item[k];
5652 81268 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5653 81268 temp_misc.shop[i].item[k+1] = swaptmp;
5654 81268 swaptmp = temp_misc.shop[i].price[k];
5655 81268 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5656 81268 temp_misc.shop[i].price[k+1] = swaptmp;
5657 81268 swaptmp = temp_misc.shop[i].hasitem[k];
5658 81268 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5659 81268 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5660 81268 }
5661 83712 }
5662 55808 }
5663 27904 }
5664
5665 //infos
5666
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 105 times.
109 if(Header->zelda_version > 0x192)
5667 {
5668
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&infos,f,true))
5669 {
5670 return qe_invalid;
5671 }
5672 105 }
5673
5674
2/2
✓ Branch 0 taken 1554 times.
✓ Branch 1 taken 109 times.
1663 for(int32_t i=0; i<infos; i++)
5675 {
5676
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 1475 times.
1554 if(s_version > 6)
5677 {
5678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1475 times.
1475 if(!pfread(temp_misc.info[i].name,sizeof(temp_misc.info[i].name),f,true))
5679 {
5680 return qe_invalid;
5681 }
5682 1475 }
5683
5684
2/2
✓ Branch 0 taken 4662 times.
✓ Branch 1 taken 1554 times.
6216 for(int32_t j=0; j<3; j++)
5685 {
5686
2/4
✓ Branch 0 taken 4470 times.
✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4662 if((Header->zelda_version < 0x192)||
5687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4470 times.
4470 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5688 {
5689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f,true))
5690 {
5691 return qe_invalid;
5692 }
5693
5694 192 temp_misc.info[i].str[j]=tempbyte;
5695 192 }
5696 else
5697 {
5698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4470 times.
4470 if(!p_igetw(&temp_misc.info[i].str[j],f,true))
5699 {
5700 return qe_invalid;
5701 }
5702 }
5703 4662 }
5704
5705
2/2
✓ Branch 0 taken 1490 times.
✓ Branch 1 taken 64 times.
1554 if(Header->zelda_version < 0x193)
5706 {
5707
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbyte,f,true))
5708 {
5709 return qe_invalid;
5710 }
5711 64 }
5712
5713
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1554 if((Header->zelda_version == 0x192)&&(Header->build>145))
5714 {
5715 if(!p_getc(&padding,f,true))
5716 {
5717 return qe_invalid;
5718 }
5719 }
5720
5721
2/2
✓ Branch 0 taken 4662 times.
✓ Branch 1 taken 1554 times.
6216 for(int32_t j=0; j<3; j++)
5722 {
5723
1/2
✓ Branch 0 taken 4662 times.
✗ Branch 1 not taken.
4662 if(!p_igetw(&temp_misc.info[i].price[j],f,true))
5724 {
5725 return qe_invalid;
5726 }
5727 4662 }
5728 1554 }
5729
5730 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5731
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<maxinfos; ++i)
5732 {
5733
2/2
✓ Branch 0 taken 55808 times.
✓ Branch 1 taken 27904 times.
83712 for(int32_t j=0; j<3-1; j++)
5734 {
5735
2/2
✓ Branch 0 taken 83712 times.
✓ Branch 1 taken 55808 times.
139520 for(int32_t k=0; k<2-j; k++)
5736 {
5737
2/2
✓ Branch 0 taken 1815 times.
✓ Branch 1 taken 81897 times.
83712 if(temp_misc.info[i].str[k]==0)
5738 {
5739 81897 swaptmp = temp_misc.info[i].str[k];
5740 81897 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5741 81897 temp_misc.info[i].str[k+1] = swaptmp;
5742 81897 swaptmp = temp_misc.info[i].price[k];
5743 81897 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5744 81897 temp_misc.info[i].price[k+1] = swaptmp;
5745 81897 }
5746 83712 }
5747 55808 }
5748 27904 }
5749
5750
5751 //warp rings
5752
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 100 times.
109 if(s_version > 5)
5753 100 warprings++;
5754
5755
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 105 times.
109 if(Header->zelda_version > 0x192)
5756 {
5757
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&warprings,f,true))
5758 {
5759 return qe_invalid;
5760 }
5761 105 }
5762
5763
2/2
✓ Branch 0 taken 1067 times.
✓ Branch 1 taken 109 times.
1176 for(int32_t i=0; i<warprings; i++)
5764 {
5765
2/2
✓ Branch 0 taken 9491 times.
✓ Branch 1 taken 1067 times.
10558 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5766 {
5767
2/2
✓ Branch 0 taken 896 times.
✓ Branch 1 taken 8595 times.
9491 if(s_version <= 3)
5768 {
5769
1/2
✓ Branch 0 taken 896 times.
✗ Branch 1 not taken.
896 if(!p_getc(&tempbyte,f,true))
5770 {
5771 return qe_invalid;
5772 }
5773
5774 896 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5775 896 }
5776 else
5777 {
5778
1/2
✓ Branch 0 taken 8595 times.
✗ Branch 1 not taken.
8595 if(!p_igetw(&temp_misc.warp[i].dmap[j],f,true))
5779 {
5780 return qe_invalid;
5781 }
5782 }
5783 9491 }
5784
5785
2/2
✓ Branch 0 taken 9491 times.
✓ Branch 1 taken 1067 times.
10558 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5786 {
5787
1/2
✓ Branch 0 taken 9491 times.
✗ Branch 1 not taken.
9491 if(!p_getc(&temp_misc.warp[i].scr[j],f,true))
5788 {
5789 return qe_invalid;
5790 }
5791 9491 }
5792
5793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1067 times.
1067 if(!p_getc(&temp_misc.warp[i].size,f,true))
5794 {
5795 return qe_invalid;
5796 }
5797
5798
2/2
✓ Branch 0 taken 1035 times.
✓ Branch 1 taken 32 times.
1067 if(Header->zelda_version < 0x193)
5799 {
5800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!p_getc(&tempbyte,f,true))
5801 {
5802 return qe_invalid;
5803 }
5804 32 }
5805 1067 }
5806
5807 //palette cycles
5808
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
109 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5809 {
5810
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int32_t i=0; i<256; i++)
5811 {
5812
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 1024 times.
4096 for(int32_t j=0; j<3; j++)
5813 {
5814 3072 temp_misc.cycles[i][j].first=0;
5815 3072 temp_misc.cycles[i][j].count=0;
5816 3072 temp_misc.cycles[i][j].speed=0;
5817 3072 }
5818 1024 }
5819
5820
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
5821 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5822 {
5823 4 palcycles=16;
5824 4 }
5825
5826
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4 times.
68 for(int32_t i=0; i<palcycles; i++)
5827 {
5828
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 64 times.
256 for(int32_t j=0; j<3; j++)
5829 {
5830
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
5831 {
5832 return qe_invalid;
5833 }
5834
5835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
5836 {
5837 return qe_invalid;
5838 }
5839
5840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
5841 {
5842 return qe_invalid;
5843 }
5844 192 }
5845 64 }
5846 4 }
5847
5848 //Wind warps are now just another warp ring.
5849
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
109 if(s_version <= 5)
5850 {
5851
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 5 times.
9 if(Header->zelda_version > 0x192)
5852 {
5853
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!p_igetw(&windwarps,f,true))
5854 {
5855 return qe_invalid;
5856 }
5857 5 }
5858
5859
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 9 times.
88 for(int32_t i=0; i<windwarps; i++)
5860 {
5861
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(s_version <= 3)
5862 {
5863
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_getc(&tempbyte,f,true))
5864 {
5865 return qe_invalid;
5866 }
5867
5868 79 temp_misc.warp[8].dmap[i]=tempbyte;
5869 79 }
5870 else
5871 {
5872 if(!p_igetw(&temp_misc.warp[8].dmap[i],f,true))
5873 {
5874 return qe_invalid;
5875 }
5876 }
5877
5878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(!p_getc(&temp_misc.warp[8].scr[i],f,true))
5879 {
5880 return qe_invalid;
5881 }
5882
5883 79 temp_misc.warp[8].size = 9;
5884
5885
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(s_version == 5)
5886 {
5887 if(!p_getc(&tempbyte,f,true))
5888 {
5889 return qe_invalid;
5890 }
5891 }
5892 79 }
5893 9 }
5894
5895
5896 //triforce pieces
5897
2/2
✓ Branch 0 taken 872 times.
✓ Branch 1 taken 109 times.
981 for(int32_t i=0; i<triforces; i++)
5898 {
5899
1/2
✓ Branch 0 taken 872 times.
✗ Branch 1 not taken.
872 if(!p_getc(&temp_misc.triforce[i],f,true))
5900 {
5901 return qe_invalid;
5902 }
5903 872 }
5904
5905 //misc color data
5906
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
109 if(s_version<3)
5907 {
5908
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.text,f,true))
5909 {
5910 return qe_invalid;
5911 }
5912
5913
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.caption,f,true))
5914 {
5915 return qe_invalid;
5916 }
5917
5918
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5919 {
5920 return qe_invalid;
5921 }
5922
5923
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5924 {
5925 return qe_invalid;
5926 }
5927
5928
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5929 {
5930 return qe_invalid;
5931 }
5932
5933
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5934 {
5935 return qe_invalid;
5936 }
5937
5938
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5939 {
5940 return qe_invalid;
5941 }
5942
5943
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5944 {
5945 return qe_invalid;
5946 }
5947
5948
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5949 {
5950 return qe_invalid;
5951 }
5952
5953
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5954 {
5955 return qe_invalid;
5956 }
5957
5958
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5959 {
5960 return qe_invalid;
5961 }
5962
5963
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5964 {
5965 return qe_invalid;
5966 }
5967
5968
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5969 {
5970 return qe_invalid;
5971 }
5972
5973
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5974 {
5975 return qe_invalid;
5976 }
5977
5978
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5979 {
5980 return qe_invalid;
5981 }
5982
5983
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5984 {
5985 return qe_invalid;
5986 }
5987
5988
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5989 {
5990 return qe_invalid;
5991 }
5992
5993
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5994 {
5995 return qe_invalid;
5996 }
5997
5998
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5999 {
6000 return qe_invalid;
6001 }
6002
6003
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
6004 {
6005 return qe_invalid;
6006 }
6007
6008
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.triforce_tile,f,true))
6009 {
6010 return qe_invalid;
6011 }
6012
6013
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.triframe_tile,f,true))
6014 {
6015 return qe_invalid;
6016 }
6017
6018
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f,true))
6019 {
6020 return qe_invalid;
6021 }
6022
6023
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f,true))
6024 {
6025 return qe_invalid;
6026 }
6027
6028
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.blueframe_tile,f,true))
6029 {
6030 return qe_invalid;
6031 }
6032
6033
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f,true))
6034 {
6035 return qe_invalid;
6036 }
6037
6038
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
6039 {
6040 return qe_invalid;
6041 }
6042
6043 9 temp_misc.colors.msgtext = 0x01;
6044
6045
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4 times.
9 if(Header->zelda_version < 0x193)
6046 {
6047
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 4 times.
32 for(int32_t i=0; i<7; i++)
6048 {
6049
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_getc(&tempbyte,f,true))
6050 {
6051 return qe_invalid;
6052 }
6053 28 }
6054 4 }
6055
6056
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if((Header->zelda_version == 0x192)&&(Header->build>145))
6057 {
6058 for(int32_t i=0; i<256; i++)
6059 {
6060 if(!p_getc(&tempbyte,f,true))
6061 {
6062 return qe_invalid;
6063 }
6064 }
6065 }
6066
6067
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(s_version>1)
6068 {
6069 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
6070 {
6071 return qe_invalid;
6072 }
6073 }
6074
6075 //save game icons
6076
2/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if((Header->zelda_version < 0x192)||
6077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6078 {
6079 4 icons=3;
6080 4 }
6081
6082
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 9 times.
41 for(int32_t i=0; i<icons; i++)
6083 {
6084
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_igetw(&temp_misc.icons[i],f,true))
6085 {
6086 return qe_invalid;
6087 }
6088 32 }
6089 9 }
6090
6091
2/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
109 if((Header->zelda_version < 0x192)||
6092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6093 {
6094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata==true)
6095 {
6096 4 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6097 4 }
6098
6099 4 return 0;
6100 }
6101
6102 //pond information
6103
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(Header->zelda_version < 0x193)
6104 {
6105 if((Header->zelda_version == 0x192)&&(Header->build<146))
6106 {
6107 pondsize=25;
6108 }
6109
6110 for(int32_t i=0; i<ponds; i++)
6111 {
6112 for(int32_t j=0; j<pondsize; j++)
6113 {
6114 if(!p_getc(&tempbyte,f,true))
6115 {
6116 return qe_invalid;
6117
6118 }
6119 }
6120 }
6121 }
6122
6123 //end string
6124
1/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
105 if((Header->zelda_version < 0x192)||
6125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6126 {
6127 if(!p_getc(&tempbyte,f,true))
6128 {
6129 return qe_invalid;
6130 }
6131
6132 temp_misc.endstring=tempbyte;
6133
6134 if(!p_getc(&tempbyte,f,true))
6135 {
6136 return qe_invalid;
6137 }
6138 }
6139 else
6140 {
6141
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&temp_misc.endstring,f,true))
6142 {
6143 return qe_invalid;
6144 }
6145 }
6146
6147 //expansion
6148
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(Header->zelda_version < 0x193)
6149 {
6150 if((Header->zelda_version == 0x192)&&(Header->build<73))
6151 {
6152 expansionsize=99*2;
6153 }
6154
6155 for(int32_t i=0; i<expansionsize; i++)
6156 {
6157 if(!p_getc(&tempbyte,f,true))
6158 {
6159 return qe_invalid;
6160 }
6161 }
6162 }
6163 //shops v8
6164
6165
6166
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 25 times.
105 if(s_version >= 8)
6167 {
6168
2/2
✓ Branch 0 taken 368 times.
✓ Branch 1 taken 25 times.
393 for(int32_t i=0; i<shops; i++)
6169 {
6170
2/2
✓ Branch 0 taken 1104 times.
✓ Branch 1 taken 368 times.
1472 for(int32_t j=0; j<3; j++)
6171 {
6172
1/2
✓ Branch 0 taken 1104 times.
✗ Branch 1 not taken.
1104 if(!p_igetw(&temp_misc.shop[i].str[j],f,true))
6173 return qe_invalid;
6174 1104 }
6175 368 }
6176 25 }
6177
6178 105 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6179 105 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6180 105 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6181
6182 //v9 includes quest misc[32]
6183
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 25 times.
105 if(s_version >= 9)
6184 {
6185
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 25 times.
825 for ( int32_t q = 0; q < 32; q++ )
6186 {
6187
1/2
✓ Branch 0 taken 800 times.
✗ Branch 1 not taken.
800 if(!p_igetl(&temp_misc.questmisc[q],f,true))
6188 return qe_invalid;
6189 800 }
6190
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 25 times.
825 for ( int32_t q = 0; q < 32; q++ )
6191 {
6192
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 800 times.
103200 for ( int32_t j = 0; j < 128; j++ )
6193
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_getc(&temp_misc.questmisc_strings[q][j],f,true))
6194 return qe_invalid;
6195 800 }
6196 25 }
6197
6198
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 80 times.
105 if(s_version >= 11 )
6199 {
6200
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f,true))
6201 return qe_invalid;
6202 25 }
6203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 else if(s_version < 11 )
6204 {
6205 80 temp_misc.zscript_last_compiled_version = -1;
6206 80 }
6207
6208 105 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6209
6210
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 80 times.
105 if(s_version >= 12)
6211 {
6212 byte spr;
6213
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t q = 0; q < sprMAX; ++q)
6214 {
6215
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&spr,f,true))
6216 return qe_invalid;
6217 6400 temp_misc.sprites[q] = spr;
6218 6400 }
6219 25 }
6220 else
6221 {
6222 80 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6223 //temp_misc.sprites[sprFALL] = ;
6224 }
6225
6226
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 80 times.
105 if(s_version >= 13)
6227 {
6228
2/2
✓ Branch 0 taken 1600 times.
✓ Branch 1 taken 25 times.
1625 for(size_t q = 0; q < 64; ++q)
6229 {
6230 1600 bottletype* bt = &(temp_misc.bottle_types[q]);
6231
1/2
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
1600 if (!pfread(bt->name, 32, f, true))
6232 return qe_invalid;
6233
2/2
✓ Branch 0 taken 4800 times.
✓ Branch 1 taken 1600 times.
6400 for(size_t j = 0; j < 3; ++j)
6234 {
6235
1/2
✓ Branch 0 taken 4800 times.
✗ Branch 1 not taken.
4800 if (!p_getc(&(bt->counter[j]), f, true))
6236 return qe_invalid;
6237
1/2
✓ Branch 0 taken 4800 times.
✗ Branch 1 not taken.
4800 if (!p_igetw(&(bt->amount[j]), f, true))
6238 return qe_invalid;
6239 4800 }
6240
1/2
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
1600 if (!p_getc(&(bt->flags), f, true))
6241 return qe_invalid;
6242
1/2
✓ Branch 0 taken 1600 times.
✗ Branch 1 not taken.
1600 if (!p_getc(&(bt->next_type), f, true))
6243 return qe_invalid;
6244 1600 }
6245
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(size_t q = 0; q < 256; ++q)
6246 {
6247 6400 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6248
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if (!pfread(bst->name, 32, f, true))
6249 return qe_invalid;
6250
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6400 times.
25600 for(size_t j = 0; j < 3; ++j)
6251 {
6252
1/2
✓ Branch 0 taken 19200 times.
✗ Branch 1 not taken.
19200 if (!p_getc(&(bst->fill[j]), f, true))
6253 return qe_invalid;
6254
1/2
✓ Branch 0 taken 19200 times.
✗ Branch 1 not taken.
19200 if (!p_igetw(&(bst->comb[j]), f, true))
6255 return qe_invalid;
6256
1/2
✓ Branch 0 taken 19200 times.
✗ Branch 1 not taken.
19200 if (!p_getc(&(bst->cset[j]), f, true))
6257 return qe_invalid;
6258
1/2
✓ Branch 0 taken 19200 times.
✗ Branch 1 not taken.
19200 if (!p_igetw(&(bst->price[j]), f, true))
6259 return qe_invalid;
6260
1/2
✓ Branch 0 taken 19200 times.
✗ Branch 1 not taken.
19200 if (!p_igetw(&(bst->str[j]), f, true))
6261 return qe_invalid;
6262 19200 }
6263 6400 }
6264 25 }
6265 else
6266 {
6267
2/2
✓ Branch 0 taken 5120 times.
✓ Branch 1 taken 80 times.
5200 for(size_t q = 0; q < 64; ++q)
6268 5120 temp_misc.bottle_types[q].clear();
6269
2/2
✓ Branch 0 taken 20480 times.
✓ Branch 1 taken 80 times.
20560 for(size_t q = 0; q < 256; ++q)
6270 20480 temp_misc.bottle_shop_types[q].clear();
6271 }
6272
6273
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 80 times.
105 if(s_version >= 14)
6274 {
6275 byte msfx;
6276
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t q = 0; q < sfxMAX; ++q)
6277 {
6278
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&msfx,f,true))
6279 return qe_invalid;
6280 6400 temp_misc.miscsfx[q] = msfx;
6281 6400 }
6282 25 }
6283 else
6284 {
6285 80 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6286 80 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6287 80 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6288 }
6289
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 80 times.
105 if(s_version < 15)
6290 {
6291 80 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6292 80 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6293 80 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6294 80 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6295 80 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6296 80 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6297 80 }
6298
6299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(keepdata==true)
6300 {
6301 105 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6302 105 }
6303
6304 105 return 0;
6305 109 }
6306
6307 extern char *item_string[ITEMCNT];
6308 extern const char *old_item_string[iLast];
6309 extern char *weapon_string[WPNCNT];
6310 extern const char *old_weapon_string[wLast];
6311
6312 109 int32_t readitems(PACKFILE *f, word version, word build, bool keepdata, bool zgpmode)
6313 {
6314 byte padding;
6315 int32_t dummy;
6316 109 word items_to_read=MAXITEMS;
6317 itemdata tempitem;
6318 109 word s_version=0, s_cversion=0;
6319 word dummy_word;
6320
6321
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if(version < 0x186)
6322 {
6323 items_to_read=64;
6324 }
6325
6326
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 105 times.
109 if(version > 0x192)
6327 {
6328 105 items_to_read=0;
6329
6330 //section version info
6331
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_version,f,true))
6332 {
6333 return qe_invalid;
6334 }
6335
6336 105 FFCore.quest_format[vItems] = s_version;
6337
6338 //al_trace("Items version %d\n", s_version);
6339
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_cversion,f,true))
6340 {
6341 return qe_invalid;
6342 }
6343
6344 //section size
6345
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy,f,true))
6346 {
6347 return qe_invalid;
6348 }
6349
6350 //finally... section data
6351
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&items_to_read,f,true))
6352 {
6353 return qe_invalid;
6354 }
6355 105 }
6356
6357
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
109 if(s_version>1)
6358 {
6359
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 100 times.
25700 for(int32_t i=0; i<items_to_read; i++)
6360 {
6361 char tempname[64];
6362
6363
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(!pfread(tempname, 64, f, keepdata))
6364 {
6365 return qe_invalid;
6366 }
6367
6368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25600 times.
25600 if(keepdata)
6369 {
6370 25600 strcpy(item_string[i], tempname);
6371 25600 }
6372 25600 }
6373 100 }
6374 else
6375 {
6376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(keepdata)
6377 {
6378
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<ITEMCNT; i++)
6379 {
6380 2304 reset_itemname(i);
6381 2304 }
6382 9 }
6383 }
6384
6385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(keepdata)
6386 {
6387
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<MAXITEMS; i++)
6388 {
6389 27904 itemdata& id = itemsbuf[i];
6390 27904 memset(&id, 0, sizeof(itemdata));
6391 27904 id.count=-1;
6392 27904 id.playsound=WAV_SCALE;
6393 27904 reset_itembuf(&id,i);
6394 27904 }
6395 109 }
6396
6397
2/2
✓ Branch 0 taken 26974 times.
✓ Branch 1 taken 109 times.
27083 for(int32_t i=0; i<items_to_read; i++)
6398 {
6399 26974 memset(&tempitem, 0, sizeof(itemdata));
6400 26974 reset_itembuf(&tempitem,i);
6401
6402
6403
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 20574 times.
26974 if ( s_version > 35 ) //expanded tiles
6404 {
6405
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.tile,f,true))
6406 {
6407 return qe_invalid;
6408 }
6409 6400 }
6410 else
6411 {
6412
1/2
✓ Branch 0 taken 20574 times.
✗ Branch 1 not taken.
20574 if(!p_igetw(&tempitem.tile,f,true))
6413 {
6414 return qe_invalid;
6415 }
6416 }
6417
6418
1/2
✓ Branch 0 taken 26974 times.
✗ Branch 1 not taken.
26974 if(!p_getc(&tempitem.misc_flags,f,true))
6419 {
6420 return qe_invalid;
6421 }
6422
6423
1/2
✓ Branch 0 taken 26974 times.
✗ Branch 1 not taken.
26974 if(!p_getc(&tempitem.csets,f,true))
6424 {
6425 return qe_invalid;
6426 }
6427
6428
1/2
✓ Branch 0 taken 26974 times.
✗ Branch 1 not taken.
26974 if(!p_getc(&tempitem.frames,f,true))
6429 {
6430 return qe_invalid;
6431 }
6432
6433
1/2
✓ Branch 0 taken 26974 times.
✗ Branch 1 not taken.
26974 if(!p_getc(&tempitem.speed,f,true))
6434 {
6435 return qe_invalid;
6436 }
6437
6438
1/2
✓ Branch 0 taken 26974 times.
✗ Branch 1 not taken.
26974 if(!p_getc(&tempitem.delay,f,true))
6439 {
6440 return qe_invalid;
6441 }
6442
6443
2/2
✓ Branch 0 taken 25950 times.
✓ Branch 1 taken 1024 times.
26974 if(version < 0x193)
6444 {
6445
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f,true))
6446 {
6447 return qe_invalid;
6448 }
6449
6450
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1024 if((version < 0x192)||((version == 0x192)&&(build<186)))
6451 {
6452
3/3
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
1024 switch(i)
6453 {
6454 case iShield:
6455 4 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-12:10;
6456 4 break;
6457
6458 case iMShield:
6459 4 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-6:-10;
6460 4 break;
6461
6462 default:
6463 1016 tempitem.ltm=0;
6464 1016 break;
6465 }
6466
6467 1024 tempitem.count=-1;
6468 1024 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6469 1024 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6470 1024 tempitem.family=0xFF;
6471 1024 tempitem.playsound=WAV_SCALE;
6472 1024 reset_itembuf(&tempitem,i);
6473
6474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 if(keepdata==true)
6475 {
6476 1024 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6477 1024 }
6478
6479 1024 continue;
6480 }
6481 }
6482
6483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25950 times.
25950 if(!p_igetl(&tempitem.ltm,f,true))
6484 {
6485 return qe_invalid;
6486 }
6487
6488
1/2
✓ Branch 0 taken 25950 times.
✗ Branch 1 not taken.
25950 if(version < 0x193)
6489 {
6490 for(int32_t q=0; q<12; q++)
6491 {
6492 if(!p_getc(&padding,f,true))
6493 {
6494 return qe_invalid;
6495 }
6496 }
6497 }
6498
6499
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 350 times.
25950 if(s_version>1)
6500 {
6501
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 19200 times.
25600 if ( s_version >= 31 )
6502 {
6503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(!p_igetl(&tempitem.family,f,true))
6504 {
6505 return qe_invalid;
6506 }
6507 6400 }
6508 else
6509 {
6510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19200 times.
19200 if(!p_getc(&tempitem.family,f,true))
6511 {
6512 return qe_invalid;
6513 }
6514 }
6515
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(s_version < 16)
6516 if(tempitem.family == 0xFF)
6517 tempitem.family = itype_misc;
6518
6519
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(!p_getc(&tempitem.fam_type,f,true))
6520 {
6521 return qe_invalid;
6522 }
6523
6524
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(s_version>5)
6525 {
6526
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 19200 times.
25600 if(s_version>=31)
6527 {
6528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(!p_igetl(&tempitem.power,f,true))
6529 {
6530 return qe_invalid;
6531 }
6532 6400 }
6533 else
6534 {
6535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19200 times.
19200 if(!p_getc(&tempitem.power,f,true))
6536 {
6537 return qe_invalid;
6538 }
6539 }
6540
6541 //converted flags from 16b to 32b -Z
6542
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6400 times.
25600 if ( s_version < 41 )
6543 {
6544
1/2
✓ Branch 0 taken 19200 times.
✗ Branch 1 not taken.
19200 if(!p_igetw(&tempitem.flags,f,true))
6545 {
6546 return qe_invalid;
6547 }
6548 19200 }
6549 else
6550 {
6551
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.flags,f,true))
6552 {
6553 return qe_invalid;
6554 }
6555 }
6556 25600 }
6557 else
6558 {
6559 //tempitem.power = tempitem.fam_type;
6560 char tempchar;
6561
6562 if(!p_getc(&tempchar,f,true))
6563 {
6564 return qe_invalid;
6565 }
6566
6567 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6568 }
6569
6570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25600 times.
25600 if(!p_igetw(&tempitem.script,f,true))
6571 {
6572 return qe_invalid;
6573 }
6574
6575
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(s_version<=3)
6576 {
6577 if(tempitem.script > NUMSCRIPTITEM)
6578 {
6579 tempitem.script = 0;
6580 }
6581 }
6582
6583
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(!p_getc(&tempitem.count,f,true))
6584 {
6585 return qe_invalid;
6586 }
6587
6588
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(!p_igetw(&tempitem.amount,f,true))
6589 {
6590 return qe_invalid;
6591 }
6592
6593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25600 times.
25600 if(!p_igetw(&tempitem.collect_script,f,true))
6594 {
6595 return qe_invalid;
6596 }
6597
6598
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(s_version<=3)
6599 {
6600 if(tempitem.collect_script > NUMSCRIPTITEM)
6601 {
6602 tempitem.collect_script = 0;
6603 }
6604 }
6605
6606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25600 times.
25600 if(!p_igetw(&tempitem.setmax,f,true))
6607 {
6608 return qe_invalid;
6609 }
6610
6611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25600 times.
25600 if(!p_igetw(&tempitem.max,f,true))
6612 {
6613 return qe_invalid;
6614 }
6615
6616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25600 times.
25600 if(!p_getc(&tempitem.playsound,f,true))
6617 {
6618 return qe_invalid;
6619 }
6620
6621
2/2
✓ Branch 0 taken 204800 times.
✓ Branch 1 taken 25600 times.
230400 for(int32_t j=0; j<8; j++)
6622 {
6623
1/2
✓ Branch 0 taken 204800 times.
✗ Branch 1 not taken.
204800 if(!p_igetl(&tempitem.initiald[j],f,true))
6624 {
6625 return qe_invalid;
6626 }
6627 204800 }
6628
6629
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 25600 times.
76800 for(int32_t j=0; j<2; j++)
6630 {
6631
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_getc(&tempitem.initiala[j],f,true))
6632 {
6633 return qe_invalid;
6634 }
6635 51200 }
6636
6637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25600 times.
25600 if(s_version>4)
6638 {
6639
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(s_version>5)
6640 {
6641
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(!p_getc(&tempitem.wpn,f,true))
6642 {
6643 return qe_invalid;
6644 }
6645
6646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25600 times.
25600 if(!p_getc(&tempitem.wpn2,f,true))
6647 {
6648 return qe_invalid;
6649 }
6650
6651
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(!p_getc(&tempitem.wpn3,f,true))
6652 {
6653 return qe_invalid;
6654 }
6655
6656
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(!p_getc(&tempitem.wpn4,f,true))
6657 {
6658 return qe_invalid;
6659 }
6660
6661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25600 times.
25600 if(s_version>=15)
6662 {
6663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25600 times.
25600 if(!p_getc(&tempitem.wpn5,f,true))
6664 {
6665 return qe_invalid;
6666 }
6667
6668
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(!p_getc(&tempitem.wpn6,f,true))
6669 {
6670 return qe_invalid;
6671 }
6672
6673
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(!p_getc(&tempitem.wpn7,f,true))
6674 {
6675 return qe_invalid;
6676 }
6677
6678
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(!p_getc(&tempitem.wpn8,f,true))
6679 {
6680 return qe_invalid;
6681 }
6682
6683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25600 times.
25600 if(!p_getc(&tempitem.wpn9,f,true))
6684 {
6685 return qe_invalid;
6686 }
6687
6688
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(!p_getc(&tempitem.wpn10,f,true))
6689 {
6690 return qe_invalid;
6691 }
6692 25600 }
6693
6694
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(!p_getc(&tempitem.pickup_hearts,f,true))
6695 {
6696 return qe_invalid;
6697 }
6698
6699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25600 times.
25600 if(s_version<15)
6700 {
6701 if(!p_igetw(&dummy_word,f,true))
6702 {
6703 return qe_invalid;
6704 }
6705
6706 tempitem.misc1=dummy_word;
6707
6708 if(!p_igetw(&dummy_word,f,true))
6709 {
6710 return qe_invalid;
6711 }
6712
6713 tempitem.misc2=dummy_word;
6714 }
6715 else
6716 {
6717
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(!p_igetl(&tempitem.misc1,f,true))
6718 {
6719 return qe_invalid;
6720 }
6721
6722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25600 times.
25600 if(!p_igetl(&tempitem.misc2,f,true))
6723 {
6724 return qe_invalid;
6725 }
6726
6727 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6728
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(s_version<24)
6729 {
6730 if(tempitem.family==itype_shield)
6731 {
6732 tempitem.misc1|=shSCRIPT;
6733 }
6734 }
6735 }
6736
6737
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6400 times.
25600 if(s_version < 53)
6738 {
6739 byte tempbyte;
6740
1/2
✓ Branch 0 taken 19200 times.
✗ Branch 1 not taken.
19200 if(!p_getc(&tempbyte,f,true))
6741 {
6742 return qe_invalid;
6743 }
6744 19200 tempitem.cost_amount[0] = tempbyte;
6745 19200 }
6746 else
6747 {
6748
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 6400 times.
19200 for(auto q = 0; q < 2; ++q)
6749 {
6750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12800 times.
12800 if(!p_igetw(&tempitem.cost_amount[q],f,true))
6751 {
6752 return qe_invalid;
6753 }
6754 12800 }
6755 }
6756 25600 }
6757 else
6758 {
6759 char tempchar;
6760
6761 if(!p_getc(&tempchar,f,true))
6762 {
6763 return qe_invalid;
6764 }
6765
6766 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6767 }
6768
6769 // June 2007: more misc. attributes
6770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25600 times.
25600 if(s_version>=12)
6771 {
6772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25600 times.
25600 if(s_version<15)
6773 {
6774 if(!p_igetw(&dummy_word,f,true))
6775 {
6776 return qe_invalid;
6777 }
6778
6779 tempitem.misc3=dummy_word;
6780
6781 if(!p_igetw(&dummy_word,f,true))
6782 {
6783 return qe_invalid;
6784 }
6785
6786 tempitem.misc4=dummy_word;
6787 }
6788 else
6789 {
6790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25600 times.
25600 if(!p_igetl(&tempitem.misc3,f,true))
6791 {
6792 return qe_invalid;
6793 }
6794
6795
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(!p_igetl(&tempitem.misc4,f,true))
6796 {
6797 return qe_invalid;
6798 }
6799
6800
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(!p_igetl(&tempitem.misc5,f,true))
6801 {
6802 return qe_invalid;
6803 }
6804
6805
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(!p_igetl(&tempitem.misc6,f,true))
6806 {
6807 return qe_invalid;
6808 }
6809
6810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25600 times.
25600 if(!p_igetl(&tempitem.misc7,f,true))
6811 {
6812 return qe_invalid;
6813 }
6814
6815
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(!p_igetl(&tempitem.misc8,f,true))
6816 {
6817 return qe_invalid;
6818 }
6819
6820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25600 times.
25600 if(!p_igetl(&tempitem.misc9,f,true))
6821 {
6822 return qe_invalid;
6823 }
6824
6825
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(!p_igetl(&tempitem.misc10,f,true))
6826 {
6827 return qe_invalid;
6828 }
6829 }
6830
6831
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(!p_getc(&tempitem.usesound,f,true))
6832 {
6833 return qe_invalid;
6834 }
6835
6836
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 19200 times.
25600 if(s_version >= 49)
6837 {
6838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(!p_getc(&tempitem.usesound2,f,true))
6839 {
6840 return qe_invalid;
6841 }
6842 6400 }
6843 19200 else tempitem.usesound2 = 0;
6844
6845
3/4
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6400 times.
✓ Branch 2 taken 19200 times.
✗ Branch 3 not taken.
25600 if(s_version < 50 && tempitem.family == itype_mirror)
6846 {
6847 //Split continue/dmap warp effect/sfx, port for old
6848 tempitem.misc2 = tempitem.misc1;
6849 tempitem.usesound2 = tempitem.usesound;
6850 }
6851 25600 }
6852 25600 }
6853
6854
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6400 times.
25600 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6855 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(!p_getc(&tempitem.useweapon,f,true))
6857 {
6858 return qe_invalid;
6859 }
6860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(!p_getc(&tempitem.usedefence,f,true))
6861 {
6862 return qe_invalid;
6863 }
6864
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(!p_igetl(&tempitem.weaprange,f,true))
6865 {
6866 return qe_invalid;
6867 }
6868
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.weapduration,f,true))
6869 {
6870 return qe_invalid;
6871 }
6872
2/2
✓ Branch 0 taken 64000 times.
✓ Branch 1 taken 6400 times.
70400 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6873 {
6874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64000 times.
64000 if(!p_igetl(&tempitem.weap_pattern[q],f,true))
6875 {
6876 return qe_invalid;
6877 }
6878 64000 }
6879 6400 }
6880
6881
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6400 times.
25600 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6882 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6883
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.duplicates,f,true))
6884 {
6885 return qe_invalid;
6886 }
6887
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 6400 times.
57600 for ( int32_t q = 0; q < INITIAL_D; q++ )
6888 {
6889
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetl(&tempitem.weap_initiald[q],f,true))
6890 {
6891 return qe_invalid;
6892 }
6893 51200 }
6894
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 6400 times.
19200 for ( int32_t q = 0; q < INITIAL_A; q++ )
6895 {
6896
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&tempitem.weap_initiala[q],f,true))
6897 {
6898 return qe_invalid;
6899 }
6900 12800 }
6901
6902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(!p_getc(&tempitem.drawlayer,f,true))
6903 {
6904 return qe_invalid;
6905 }
6906
6907
6908
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.hxofs,f,true))
6909 {
6910 return qe_invalid;
6911 }
6912
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.hyofs,f,true))
6913 {
6914 return qe_invalid;
6915 }
6916
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.hxsz,f,true))
6917 {
6918 return qe_invalid;
6919 }
6920
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.hysz,f,true))
6921 {
6922 return qe_invalid;
6923 }
6924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(!p_igetl(&tempitem.hzsz,f,true))
6925 {
6926 return qe_invalid;
6927 }
6928
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.xofs,f,true))
6929 {
6930 return qe_invalid;
6931 }
6932
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.yofs,f,true))
6933 {
6934 return qe_invalid;
6935 }
6936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(!p_igetl(&tempitem.weap_hxofs,f,true))
6937 {
6938 return qe_invalid;
6939 }
6940
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.weap_hyofs,f,true))
6941 {
6942 return qe_invalid;
6943 }
6944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(!p_igetl(&tempitem.weap_hxsz,f,true))
6945 {
6946 return qe_invalid;
6947 }
6948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(!p_igetl(&tempitem.weap_hysz,f,true))
6949 {
6950 return qe_invalid;
6951 }
6952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(!p_igetl(&tempitem.weap_hzsz,f,true))
6953 {
6954 return qe_invalid;
6955 }
6956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(!p_igetl(&tempitem.weap_xofs,f,true))
6957 {
6958 return qe_invalid;
6959 }
6960
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.weap_yofs,f,true))
6961 {
6962 return qe_invalid;
6963 }
6964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(!p_igetw(&tempitem.weaponscript,f,true))
6965 {
6966 return qe_invalid;
6967 }
6968
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.wpnsprite,f,true))
6969 {
6970 return qe_invalid;
6971 }
6972 6400 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6973
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 6400 times.
19200 for(auto q = 0; q < num_cost_tmr; ++q)
6974 {
6975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12800 times.
12800 if(!p_igetl(&tempitem.magiccosttimer[q],f,true))
6976 {
6977 return qe_invalid;
6978 }
6979 12800 }
6980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 for(auto q = num_cost_tmr; q < 2; ++q)
6981 tempitem.magiccosttimer[q] = 0;
6982 6400 }
6983
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6400 times.
25600 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6984 {
6985 //Item Size FLags, TileWidth, TileHeight
6986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(!p_igetl(&tempitem.overrideFLAGS,f,true))
6987 {
6988 return qe_invalid;
6989 }
6990
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.tilew,f,true))
6991 {
6992 return qe_invalid;
6993 }
6994
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.tileh,f,true))
6995 {
6996 return qe_invalid;
6997 }
6998 6400 }
6999
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6400 times.
25600 if ( s_version >= 29 ) //! More new vars.
7000 {
7001 //Item Size FLags, TileWidth, TileHeight
7002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(!p_igetl(&tempitem.weapoverrideFLAGS,f,true))
7003 {
7004 return qe_invalid;
7005 }
7006
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.weap_tilew,f,true))
7007 {
7008 return qe_invalid;
7009 }
7010
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.weap_tileh,f,true))
7011 {
7012 return qe_invalid;
7013 }
7014 6400 }
7015
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6400 times.
25600 if ( s_version >= 30 ) //! More new vars.
7016 {
7017 //Pickup Type
7018
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempitem.pickup,f,true))
7019 {
7020 return qe_invalid;
7021 }
7022 6400 }
7023
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6400 times.
25600 if ( s_version >= 32 ) //! More new vars.
7024 {
7025 //Pickup Type
7026
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetw(&tempitem.pstring,f,true))
7027 {
7028 return qe_invalid;
7029 }
7030 6400 }
7031
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6400 times.
25600 if ( s_version >= 33 ) //! More new vars.
7032 {
7033 //Pickup Type
7034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(!p_igetw(&tempitem.pickup_string_flags,f,true))
7035 {
7036 return qe_invalid;
7037 }
7038 6400 }
7039
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6400 times.
25600 if ( s_version >= 34 ) //! cost counter
7040 {
7041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6400 times.
6400 if(s_version < 53)
7042 {
7043 if(!p_getc(&tempitem.cost_counter[0],f,true))
7044 {
7045 return qe_invalid;
7046 }
7047 }
7048 else
7049 {
7050
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 6400 times.
19200 for(auto q = 0; q < 2; ++q)
7051 {
7052
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&tempitem.cost_counter[q],f,true))
7053 {
7054 return qe_invalid;
7055 }
7056 12800 }
7057 }
7058 6400 }
7059
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6400 times.
25600 if ( s_version >= 44 ) //! sprite scripts
7060 {
7061
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 6400 times.
57600 for ( int32_t q = 0; q < 8; q++ )
7062 {
7063
2/2
✓ Branch 0 taken 3328000 times.
✓ Branch 1 taken 51200 times.
3379200 for ( int32_t w = 0; w < 65; w++ )
7064 {
7065
1/2
✓ Branch 0 taken 3328000 times.
✗ Branch 1 not taken.
3328000 if(!p_getc(&(tempitem.initD_label[q][w]),f,keepdata))
7066 {
7067 return qe_invalid;
7068 }
7069 3328000 }
7070
2/2
✓ Branch 0 taken 3328000 times.
✓ Branch 1 taken 51200 times.
3379200 for ( int32_t w = 0; w < 65; w++ )
7071 {
7072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3328000 times.
3328000 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f,keepdata))
7073 {
7074 return qe_invalid;
7075 }
7076 3328000 }
7077
2/2
✓ Branch 0 taken 3328000 times.
✓ Branch 1 taken 51200 times.
3379200 for ( int32_t w = 0; w < 65; w++ )
7078 {
7079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3328000 times.
3328000 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f,keepdata))
7080 {
7081 return qe_invalid;
7082 }
7083 3328000 }
7084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
51200 if(!p_igetl(&(tempitem.sprite_initiald[q]),f,keepdata))
7085 {
7086 return qe_invalid;
7087 }
7088
7089 51200 }
7090
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 6400 times.
19200 for ( int32_t q = 0; q < 2; q++ )
7091 {
7092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12800 times.
12800 if(!p_getc(&(tempitem.sprite_initiala[q]),f,keepdata))
7093 {
7094 return qe_invalid;
7095 }
7096 12800 }
7097 //Pickup Type
7098
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetw(&tempitem.sprite_script,f,true))
7099 {
7100 return qe_invalid;
7101 }
7102 6400 }
7103
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 6400 times.
25600 if ( s_version >= 48 ) //! pickup flags
7104 {
7105
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_getc(&(tempitem.pickupflag),f,keepdata))
7106 {
7107 return qe_invalid;
7108 }
7109 6400 }
7110
2/2
✓ Branch 0 taken 23296 times.
✓ Branch 1 taken 2304 times.
25600 if ( s_version >= 57 )
7111 {
7112 2304 std::string str;
7113
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2304 times.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getcstr(&str,f,true))
7114 return qe_invalid;
7115 2304 strncpy(tempitem.display_name,str.c_str(),255);
7116
1/3
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2304 }
7117 25600 }
7118 else
7119 {
7120 350 tempitem.count=-1;
7121 350 tempitem.family=itype_misc;
7122 350 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7123 350 tempitem.playsound=WAV_SCALE;
7124 350 reset_itembuf(&tempitem,i);
7125 }
7126
7127
1/2
✓ Branch 0 taken 25950 times.
✗ Branch 1 not taken.
25950 if(keepdata==true)
7128 {
7129 25950 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7130 25950 }
7131 else if(zgpmode)
7132 {
7133 itemsbuf[i].tile=tempitem.tile;
7134 itemsbuf[i].misc_flags=tempitem.misc_flags;
7135 itemsbuf[i].csets=tempitem.csets;
7136 itemsbuf[i].frames=tempitem.frames;
7137 itemsbuf[i].speed=tempitem.speed;
7138 itemsbuf[i].delay=tempitem.delay;
7139 itemsbuf[i].ltm=tempitem.ltm;
7140 }
7141 25950 }
7142
7143 //////////////////////////////////////////////////////
7144 // Now do any updates because of new item additions
7145 // (These can't be done above because items_to_read
7146 // might be too low.)
7147 //////////////////////////////////////////////////////
7148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(keepdata==true)
7149 {
7150
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<MAXITEMS; i++)
7151 {
7152 27904 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7153
7154 //Account for older quests that didn't have an actual item for the used letter
7155
4/4
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 25600 times.
✓ Branch 2 taken 2295 times.
✓ Branch 3 taken 9 times.
27904 if(s_version < 2 && i==iLetterUsed)
7156 {
7157 9 reset_itembuf(&tempitem, iLetterUsed);
7158 9 strcpy(item_string[i],old_item_string[i]);
7159 9 tempitem.tile = itemsbuf[iLetter].tile;
7160 9 tempitem.csets = itemsbuf[iLetter].csets;
7161 9 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7162 9 tempitem.frames = itemsbuf[iLetter].frames;
7163 9 tempitem.speed = itemsbuf[iLetter].speed;
7164 9 tempitem.ltm = itemsbuf[iLetter].ltm;
7165 9 }
7166
7167
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 2304 times.
27904 if(s_version < 3)
7168 {
7169
3/3
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 2097 times.
✓ Branch 2 taken 9 times.
2304 switch(i)
7170 {
7171 case iRocsFeather:
7172 case iHoverBoots:
7173 case iSpinScroll:
7174 case iL2SpinScroll:
7175 case iCrossScroll:
7176 case iQuakeScroll:
7177 case iL2QuakeScroll:
7178 case iWhispRing:
7179 case iL2WhispRing:
7180 case iChargeRing:
7181 case iL2ChargeRing:
7182 case iPerilScroll:
7183 case iWalletL3:
7184 case iQuiverL4:
7185 case iBombBagL4:
7186 case iBracelet:
7187 case iL2Bracelet:
7188 case iOldGlove:
7189 case iL2Ladder:
7190 case iWealthMedal:
7191 case iL2WealthMedal:
7192 case iL3WealthMedal:
7193 198 reset_itembuf(&tempitem, i);
7194 198 strcpy(item_string[i],old_item_string[i]);
7195 198 break;
7196
7197 case iSShield:
7198 9 reset_itembuf(&tempitem, i);
7199 9 strcpy(item_string[i],old_item_string[i]);
7200 9 strcpy(item_string[iShield],old_item_string[iShield]);
7201 9 strcpy(item_string[iMShield],old_item_string[iMShield]);
7202 9 break;
7203 }
7204 2304 }
7205
7206
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 2304 times.
27904 if(s_version < 5)
7207 {
7208
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 2241 times.
2304 switch(i)
7209 {
7210 case iHeartRing:
7211 case iL2HeartRing:
7212 case iL3HeartRing:
7213 case iMagicRing:
7214 case iL2MagicRing:
7215 case iL3MagicRing:
7216 case iL4MagicRing:
7217 63 reset_itembuf(&tempitem, i);
7218 63 strcpy(item_string[i],old_item_string[i]);
7219 63 break;
7220 }
7221 2304 }
7222
7223
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 2304 times.
27904 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7224 {
7225
4/4
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 2286 times.
2304 if(i!=iBPotion && i!=iRPotion)
7226 2286 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7227
7228
43/43
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 1899 times.
✓ Branch 8 taken 9 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 9 times.
✓ Branch 11 taken 9 times.
✓ Branch 12 taken 9 times.
✓ Branch 13 taken 9 times.
✓ Branch 14 taken 9 times.
✓ Branch 15 taken 9 times.
✓ Branch 16 taken 9 times.
✓ Branch 17 taken 9 times.
✓ Branch 18 taken 9 times.
✓ Branch 19 taken 9 times.
✓ Branch 20 taken 9 times.
✓ Branch 21 taken 9 times.
✓ Branch 22 taken 9 times.
✓ Branch 23 taken 9 times.
✓ Branch 24 taken 9 times.
✓ Branch 25 taken 9 times.
✓ Branch 26 taken 9 times.
✓ Branch 27 taken 9 times.
✓ Branch 28 taken 9 times.
✓ Branch 29 taken 9 times.
✓ Branch 30 taken 9 times.
✓ Branch 31 taken 9 times.
✓ Branch 32 taken 9 times.
✓ Branch 33 taken 9 times.
✓ Branch 34 taken 9 times.
✓ Branch 35 taken 9 times.
✓ Branch 36 taken 9 times.
✓ Branch 37 taken 9 times.
✓ Branch 38 taken 9 times.
✓ Branch 39 taken 9 times.
✓ Branch 40 taken 9 times.
✓ Branch 41 taken 9 times.
✓ Branch 42 taken 9 times.
2304 switch(i)
7229 {
7230 case iTriforce:
7231 9 tempitem.fam_type=1;
7232 9 break;
7233
7234 case iBigTri:
7235 9 tempitem.fam_type=0;
7236 9 break;
7237
7238 case iBombs:
7239 9 tempitem.fam_type=i_bomb;
7240 9 tempitem.power=4;
7241 9 tempitem.wpn=wBOMB;
7242 9 tempitem.wpn2=wBOOM;
7243 9 tempitem.misc1 = 50;
7244
7245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 200; //qr_SLOWBOMBFUSES
7246
7247 9 break;
7248
7249 case iSBomb:
7250 9 tempitem.fam_type=i_sbomb;
7251 9 tempitem.power=16;
7252 9 tempitem.wpn=wSBOMB;
7253 9 tempitem.wpn2=wSBOOM;
7254 9 tempitem.misc1 = 50;
7255
7256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 400; //qr_SLOWBOMBFUSES
7257
7258 9 break;
7259
7260 case iBook:
7261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(get_bit(deprecated_rules, 113))
7262 tempitem.wpn = wFIREMAGIC; //qr_FIREMAGICSPRITE
7263
7264 9 break;
7265
7266 case iSArrow:
7267 9 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7268 9 tempitem.power=4;
7269 9 tempitem.flags|=ITEM_GAMEDATA;
7270 9 tempitem.wpn=wSARROW;
7271 9 break;
7272
7273 case iGArrow:
7274 9 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7275 9 tempitem.power=8;
7276 9 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7277 9 tempitem.wpn=wGARROW;
7278 9 break;
7279
7280 case iBrang:
7281 9 tempitem.power=0;
7282 9 tempitem.wpn=wBRANG;
7283 9 tempitem.misc1=36;
7284 9 break;
7285
7286 case iMBrang:
7287 9 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7288 9 tempitem.power=0;
7289 9 tempitem.wpn=wMBRANG;
7290 9 break;
7291
7292 case iFBrang:
7293 9 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7294 9 tempitem.power=2;
7295 9 tempitem.wpn=wFBRANG;
7296 9 break;
7297
7298 case iBoots:
7299 9 tempitem.cost_amount[0] = get_bit(deprecated_rules,51) ? 1 : 0;
7300 9 tempitem.power=7;
7301 9 break;
7302
7303 case iWand:
7304 9 tempitem.cost_amount[0] = get_bit(deprecated_rules,49) ? 8 : 0;
7305 9 tempitem.power=2;
7306 9 tempitem.wpn=wWAND;
7307 9 tempitem.wpn3=wMAGIC;
7308 9 break;
7309
7310 case iBCandle:
7311 9 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7312 9 tempitem.power=1;
7313 9 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7314 9 tempitem.wpn3=wFIRE;
7315 9 break;
7316
7317 case iRCandle:
7318 9 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7319 9 tempitem.power=1;
7320 9 tempitem.wpn3=wFIRE;
7321 9 break;
7322
7323 case iSword:
7324 9 tempitem.power=1;
7325 9 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7326 9 tempitem.wpn=tempitem.wpn3=wSWORD;
7327 9 tempitem.wpn2=wSWORDSLASH;
7328 9 break;
7329
7330 case iWSword:
7331 9 tempitem.power=2;
7332 9 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7333 9 tempitem.wpn=tempitem.wpn3=wWSWORD;
7334 9 tempitem.wpn2=wWSWORDSLASH;
7335 9 break;
7336
7337 case iMSword:
7338 9 tempitem.power=4;
7339 9 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7340 9 tempitem.wpn=tempitem.wpn3=wMSWORD;
7341 9 tempitem.wpn2=wMSWORDSLASH;
7342 9 break;
7343
7344 case iXSword:
7345 9 tempitem.power=8;
7346 9 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7347 9 tempitem.wpn=tempitem.wpn3=wXSWORD;
7348 9 tempitem.wpn2=wXSWORDSLASH;
7349 9 break;
7350
7351 case iDivineProtection:
7352 9 tempitem.flags |= get_bit(deprecated_rules,76) ? ITEM_FLAG1 : 0;
7353 9 tempitem.flags |= get_bit(deprecated_rules,75) ? ITEM_FLAG2 : 0;
7354 9 tempitem.wpn=wDIVINEPROTECTION1A;
7355 9 tempitem.wpn2=wDIVINEPROTECTION1B;
7356 9 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7357 9 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7358 9 tempitem.wpn6=wDIVINEPROTECTION2A;
7359 9 tempitem.wpn7=wDIVINEPROTECTION2B;
7360 9 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7361 9 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7362 9 tempitem.wpn5 = iwDivineProtectionShieldFront;
7363 9 tempitem.wpn10 = iwDivineProtectionShieldBack;
7364 9 tempitem.misc1=512;
7365 9 tempitem.cost_amount[0]=64;
7366 9 break;
7367
7368 case iLens:
7369 9 tempitem.misc1=60;
7370 9 tempitem.flags |= get_bit(quest_rules,qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7371 9 tempitem.cost_amount[0] = get_bit(quest_rules,qr_ENABLEMAGIC) ? 2 : 1;
7372 9 break;
7373
7374 case iArrow:
7375 9 tempitem.power=2;
7376 9 tempitem.wpn=wARROW;
7377 9 break;
7378
7379 case iHoverBoots:
7380 9 tempitem.misc1=45;
7381 9 tempitem.wpn=iwHover;
7382 9 break;
7383
7384 case iDivineFire:
7385 9 tempitem.power=8;
7386 9 tempitem.wpn=wDIVINEFIRE1A;
7387 9 tempitem.wpn2=wDIVINEFIRE1B;
7388 9 tempitem.wpn3=wDIVINEFIRES1A;
7389 9 tempitem.wpn4=wDIVINEFIRES1B;
7390 9 tempitem.misc1 = 32;
7391 9 tempitem.misc2 = 200;
7392 9 tempitem.cost_amount[0]=32;
7393 9 break;
7394
7395 case iDivineEscape:
7396 9 tempitem.cost_amount[0]=32;
7397 9 break;
7398
7399 case iHookshot:
7400 9 tempitem.power=0;
7401 9 tempitem.flags&=~ITEM_FLAG1;
7402 9 tempitem.wpn=wHSHEAD;
7403 9 tempitem.wpn2=wHSCHAIN_H;
7404 9 tempitem.wpn4=wHSHANDLE;
7405 9 tempitem.wpn3=wHSCHAIN_V;
7406 9 tempitem.misc1=50;
7407 9 tempitem.misc2=100;
7408 9 break;
7409
7410 case iLongshot:
7411 9 tempitem.power=0;
7412 9 tempitem.flags&=~ITEM_FLAG1;
7413 9 tempitem.wpn=wLSHEAD;
7414 9 tempitem.wpn2=wLSCHAIN_H;
7415 9 tempitem.wpn4=wLSHANDLE;
7416 9 tempitem.wpn3=wLSCHAIN_V;
7417 9 tempitem.misc1=99;
7418 9 tempitem.misc2=100;
7419 9 break;
7420
7421 case iHammer:
7422 9 tempitem.power=4;
7423 9 tempitem.wpn=wHAMMER;
7424 9 tempitem.wpn2=iwHammerSmack;
7425 9 break;
7426
7427 case iCByrna:
7428 9 tempitem.power=1;
7429 9 tempitem.wpn=wCBYRNA;
7430 9 tempitem.wpn2=wCBYRNASLASH;
7431 9 tempitem.wpn3=wCBYRNAORB;
7432 9 tempitem.misc1=4;
7433 9 tempitem.misc2=16;
7434 9 tempitem.misc3=1;
7435 9 tempitem.cost_amount[0]=1;
7436 9 break;
7437
7438 case iWhistle:
7439 9 tempitem.wpn=wWIND;
7440 9 tempitem.misc1=3;
7441 9 tempitem.flags|=ITEM_FLAG1;
7442 9 break;
7443
7444 case iBRing:
7445 9 tempitem.power=2;
7446 9 tempitem.misc1=spBLUE;
7447 9 break;
7448
7449 case iRRing:
7450 9 tempitem.power=4;
7451 9 tempitem.misc1=spRED;
7452 9 break;
7453
7454 case iGRing:
7455 9 tempitem.power=8;
7456 9 tempitem.misc1=spGOLD;
7457 9 break;
7458
7459 case iSpinScroll:
7460 9 tempitem.power = 2;
7461 9 tempitem.misc1 = 1;
7462 9 break;
7463
7464 case iL2SpinScroll:
7465 9 tempitem.family=itype_spinscroll2;
7466 9 tempitem.fam_type=1;
7467 9 tempitem.cost_amount[0]=8;
7468 9 tempitem.power=2;
7469 9 tempitem.misc1 = 20;
7470 9 break;
7471
7472 case iQuakeScroll:
7473 9 tempitem.misc1=0x10;
7474 9 tempitem.misc2=64;
7475 9 break;
7476
7477 case iL2QuakeScroll:
7478 9 tempitem.family=itype_quakescroll2;
7479 9 tempitem.fam_type=1;
7480 9 tempitem.power = 2;
7481 9 tempitem.misc1=0x20;
7482 9 tempitem.misc2=192;
7483 9 tempitem.cost_amount[0]=8;
7484 9 break;
7485
7486 case iChargeRing:
7487 9 tempitem.misc1=64;
7488 9 tempitem.misc2=128;
7489 9 break;
7490
7491 case iL2ChargeRing:
7492 9 tempitem.misc1=32;
7493 9 tempitem.misc2=64;
7494 9 break;
7495
7496 case iOldGlove:
7497 9 tempitem.flags |= ITEM_FLAG1;
7498
7499 //fallthrough
7500 case iBombBagL4:
7501 case iWalletL3:
7502 case iQuiverL4:
7503 case iBracelet:
7504 45 tempitem.power = 1;
7505 45 break;
7506
7507 case iL2Bracelet:
7508 9 tempitem.power = 2;
7509 9 break;
7510
7511 case iMKey:
7512 9 tempitem.power=0xFF;
7513 9 tempitem.flags |= ITEM_FLAG1;
7514 9 break;
7515 }
7516 2304 }
7517
7518
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 2304 times.
27904 if(s_version < 7)
7519 {
7520
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 2268 times.
2304 switch(i)
7521 {
7522 case iStoneAgony:
7523 case iStompBoots:
7524 case iPerilRing:
7525 case iWhimsicalRing:
7526 {
7527 36 reset_itembuf(&tempitem, i);
7528 36 strcpy(item_string[i],old_item_string[i]);
7529 36 break;
7530 }
7531 }
7532 2304 }
7533
7534
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 2304 times.
27904 if(s_version < 8) // May 2007: Some corrections.
7535 {
7536
7/7
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 2232 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 9 times.
2304 switch(i)
7537 {
7538 case iMShield:
7539 9 tempitem.misc1|=shFLAME;
7540 9 tempitem.misc2|=shFIREBALL|shMAGIC;
7541
7542
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(get_bit(quest_rules, qr_SWORDMIRROR))
7543 {
7544 tempitem.misc2 |= shSWORD;
7545 }
7546
7547 // fallthrough
7548 case iShield:
7549 18 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7550
7551 // fallthrough
7552 case iSShield:
7553 27 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7554
7555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7556 {
7557 tempitem.misc2 |= shROCK;
7558 }
7559
7560 27 break;
7561
7562 case iWhispRing:
7563 9 tempitem.power=1;
7564 9 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7565 9 tempitem.misc1 = 3;
7566 9 break;
7567
7568 case iL2WhispRing:
7569 9 tempitem.power=0;
7570 9 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7571 9 tempitem.misc1 = 3;
7572 9 break;
7573
7574 case iL2Ladder:
7575 case iBow:
7576 case iCByrna:
7577 27 tempitem.power = 1;
7578 27 break;
7579 }
7580 2304 }
7581
7582
4/4
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 25600 times.
✓ Branch 2 taken 2295 times.
✓ Branch 3 taken 9 times.
27904 if(s_version < 9 && i==iClock)
7583 {
7584 9 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7585 9 }
7586
7587 //add the misc flag for bomb
7588
4/4
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 25600 times.
✓ Branch 2 taken 2295 times.
✓ Branch 3 taken 9 times.
27904 if(s_version < 10 && tempitem.family == itype_bomb)
7589 {
7590 9 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_bit(quest_rules, qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7591 9 }
7592
7593
4/4
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 25600 times.
✓ Branch 2 taken 2286 times.
✓ Branch 3 taken 18 times.
27904 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7594 {
7595 18 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7596 18 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7597 18 }
7598
7599
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 2304 times.
27904 if(s_version < 12) // June 2007: More Misc. attributes.
7600 {
7601
5/5
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 2259 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
2304 switch(i)
7602 {
7603 case iFBrang:
7604 9 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7605
7606 //fallthrough
7607 case iMBrang:
7608 18 tempitem.misc3 |= shSWORD|shMAGIC;
7609
7610 //fallthrough
7611 case iHookshot:
7612 case iLongshot:
7613 //fallthrough
7614 36 tempitem.misc3 |= shFIREBALL;
7615
7616 case iBrang:
7617 45 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7618 45 break;
7619 }
7620
7621
16/16
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 36 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 1298 times.
✓ Branch 8 taken 9 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 27 times.
✓ Branch 12 taken 27 times.
✓ Branch 13 taken 781 times.
✓ Branch 14 taken 9 times.
✓ Branch 15 taken 9 times.
2304 switch(tempitem.family)
7622 {
7623 case itype_hoverboots:
7624 9 tempitem.usesound = WAV_ZN1HOVER;
7625 9 break;
7626
7627 case itype_wand:
7628 9 tempitem.usesound = WAV_WAND;
7629 9 break;
7630
7631 case itype_book:
7632 9 tempitem.usesound = WAV_FIRE;
7633 9 break;
7634
7635 case itype_arrow:
7636 27 tempitem.usesound = WAV_ARROW;
7637 27 break;
7638
7639 case itype_hookshot:
7640 18 tempitem.usesound = WAV_HOOKSHOT;
7641 18 break;
7642
7643 case itype_brang:
7644 27 tempitem.usesound = WAV_BRANG;
7645 27 break;
7646
7647 case itype_shield:
7648 27 tempitem.usesound = WAV_CHINK;
7649 27 break;
7650
7651 case itype_sword:
7652 781 tempitem.usesound = WAV_SWORD;
7653 781 break;
7654
7655 case itype_whistle:
7656 9 tempitem.usesound = WAV_WHISTLE;
7657 9 break;
7658
7659 case itype_hammer:
7660 9 tempitem.usesound = WAV_HAMMER;
7661 9 break;
7662
7663 case itype_divinefire:
7664 9 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7665 9 break;
7666
7667 case itype_divineescape:
7668 9 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7669 9 break;
7670
7671 case itype_divineprotection:
7672 9 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7673 9 break;
7674
7675 case itype_bomb:
7676 case itype_sbomb:
7677 case itype_quakescroll:
7678 case itype_quakescroll2:
7679 36 tempitem.usesound = WAV_BOMB;
7680 36 break;
7681
7682 case itype_spinscroll:
7683 case itype_spinscroll2:
7684 18 tempitem.usesound = WAV_ZN1SPINATTACK;
7685 18 break;
7686 }
7687 2304 }
7688
7689
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 2304 times.
27904 if(s_version < 13) // July 2007
7690 {
7691
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2295 times.
2304 if(tempitem.family == itype_whistle)
7692 {
7693 9 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7694 9 tempitem.power = 1;
7695 9 tempitem.flags|=ITEM_FLAG1;
7696 9 }
7697
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2286 times.
2295 else if(tempitem.family == itype_wand)
7698 9 tempitem.flags|=ITEM_FLAG1;
7699
2/2
✓ Branch 0 taken 2277 times.
✓ Branch 1 taken 9 times.
2286 else if(tempitem.family == itype_book)
7700 {
7701 9 tempitem.flags|=ITEM_FLAG1;
7702 9 tempitem.power = 2;
7703 9 }
7704 2304 }
7705
7706
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 2304 times.
27904 if(s_version < 14) // August 2007
7707 {
7708
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 2286 times.
2304 if(tempitem.family == itype_fairy)
7709 {
7710 18 tempitem.usesound = WAV_SCALE;
7711
7712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(tempitem.fam_type)
7713 18 tempitem.misc3=50;
7714 18 }
7715
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 18 times.
2286 else if(tempitem.family == itype_potion)
7716 {
7717 18 tempitem.flags |= ITEM_GAINOLD;
7718 18 }
7719 2304 }
7720
7721
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 2304 times.
27904 if(s_version < 17) // November 2007
7722 {
7723
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 2286 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
2304 if(tempitem.family == itype_candle && !tempitem.wpn3)
7724 {
7725 tempitem.wpn3 = wFIRE;
7726 }
7727
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 2277 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9 times.
2304 else if(tempitem.family == itype_arrow && tempitem.power>4)
7728 {
7729 9 tempitem.flags|=ITEM_FLAG1;
7730 9 }
7731 2304 }
7732
7733
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 2304 times.
27904 if(s_version < 18) // New Year's Eve 2007
7734 {
7735
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2295 times.
2304 if(tempitem.family == itype_whistle)
7736 9 tempitem.misc2 = 8; // Use the Whistle warp ring
7737
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2286 times.
2295 else if(tempitem.family == itype_bait)
7738 9 tempitem.misc1 = 768; // Frames until it goes
7739
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 18 times.
2286 else if(tempitem.family == itype_triforcepiece)
7740 {
7741
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 if(tempitem.flags & ITEM_GAMEDATA)
7742 {
7743 9 tempitem.misc2 = 1; // Cutscene 1
7744 9 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7745 9 }
7746 18 }
7747 2304 }
7748
7749
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 2304 times.
27904 if(s_version < 19) // January 2008
7750 {
7751
2/2
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
2304 if(tempitem.family == itype_divineprotection)
7752 {
7753 9 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7754 9 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7755 9 }
7756 2304 }
7757
7758
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 2304 times.
27904 if(s_version < 20) // October 2008
7759 {
7760
2/2
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
2304 if(tempitem.family == itype_divineprotection)
7761 {
7762 9 tempitem.wpn6=wDIVINEPROTECTION2A;
7763 9 tempitem.wpn7=wDIVINEPROTECTION2B;
7764 9 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7765 9 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7766 9 tempitem.wpn5 = iwDivineProtectionShieldFront;
7767 9 tempitem.wpn10 = iwDivineProtectionShieldBack;
7768 9 }
7769 2304 }
7770
7771
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 2304 times.
27904 if(s_version < 21) // November 2008
7772 {
7773
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if(tempitem.flags & 0x0100) // ITEM_SLASH
7774 {
7775 tempitem.flags &= ~0x0100;
7776
7777 if(tempitem.family == itype_sword ||
7778 tempitem.family == itype_wand ||
7779 tempitem.family == itype_candle ||
7780 tempitem.family == itype_cbyrna)
7781 {
7782 tempitem.flags |= ITEM_FLAG4;
7783 }
7784 }
7785 2304 }
7786
7787
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 2304 times.
27904 if(s_version < 22) // September 2009
7788 {
7789
4/4
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 2286 times.
2304 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7790 {
7791 18 tempitem.misc3 = tempitem.power/2;
7792 18 }
7793 2304 }
7794
7795
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 2304 times.
27904 if(s_version < 23) // March 2011
7796 {
7797
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2295 times.
2304 if(tempitem.family == itype_divinefire)
7798 9 tempitem.wpn5 = wFIRE;
7799
2/2
✓ Branch 0 taken 2286 times.
✓ Branch 1 taken 9 times.
2295 else if(tempitem.family == itype_book)
7800 9 tempitem.wpn2 = wFIRE;
7801 2304 }
7802
7803 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7804 // whether it was or not, and a lot of existing quests depended on the
7805 // incorrect behavior.
7806
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 2304 times.
27904 if(s_version < 25) // January 2012
7807 {
7808
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 36 times.
2304 if(tempitem.family == itype_bombbag)
7809 36 tempitem.flags |= 16;
7810
7811
2/2
✓ Branch 0 taken 2295 times.
✓ Branch 1 taken 9 times.
2304 if(tempitem.family == itype_divinefire)
7812 9 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7813 2304 }
7814
7815
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 21504 times.
27904 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7816 {
7817
60/60
✓ Branch 0 taken 6823 times.
✓ Branch 1 taken 250 times.
✓ Branch 2 taken 249 times.
✓ Branch 3 taken 204 times.
✓ Branch 4 taken 129 times.
✓ Branch 5 taken 84 times.
✓ Branch 6 taken 166 times.
✓ Branch 7 taken 166 times.
✓ Branch 8 taken 98 times.
✓ Branch 9 taken 275 times.
✓ Branch 10 taken 249 times.
✓ Branch 11 taken 165 times.
✓ Branch 12 taken 256 times.
✓ Branch 13 taken 166 times.
✓ Branch 14 taken 83 times.
✓ Branch 15 taken 166 times.
✓ Branch 16 taken 98 times.
✓ Branch 17 taken 83 times.
✓ Branch 18 taken 252 times.
✓ Branch 19 taken 84 times.
✓ Branch 20 taken 85 times.
✓ Branch 21 taken 166 times.
✓ Branch 22 taken 83 times.
✓ Branch 23 taken 84 times.
✓ Branch 24 taken 83 times.
✓ Branch 25 taken 83 times.
✓ Branch 26 taken 83 times.
✓ Branch 27 taken 98 times.
✓ Branch 28 taken 83 times.
✓ Branch 29 taken 84 times.
✓ Branch 30 taken 83 times.
✓ Branch 31 taken 84 times.
✓ Branch 32 taken 166 times.
✓ Branch 33 taken 332 times.
✓ Branch 34 taken 85 times.
✓ Branch 35 taken 83 times.
✓ Branch 36 taken 150 times.
✓ Branch 37 taken 332 times.
✓ Branch 38 taken 83 times.
✓ Branch 39 taken 83 times.
✓ Branch 40 taken 83 times.
✓ Branch 41 taken 83 times.
✓ Branch 42 taken 83 times.
✓ Branch 43 taken 167 times.
✓ Branch 44 taken 166 times.
✓ Branch 45 taken 83 times.
✓ Branch 46 taken 250 times.
✓ Branch 47 taken 251 times.
✓ Branch 48 taken 336 times.
✓ Branch 49 taken 83 times.
✓ Branch 50 taken 83 times.
✓ Branch 51 taken 83 times.
✓ Branch 52 taken 83 times.
✓ Branch 53 taken 83 times.
✓ Branch 54 taken 84 times.
✓ Branch 55 taken 2252 times.
✓ Branch 56 taken 892 times.
✓ Branch 57 taken 250 times.
✓ Branch 58 taken 1035 times.
✓ Branch 59 taken 2615 times.
21504 switch(tempitem.family)
7818 {
7819 case itype_sword:
7820 {
7821 6823 tempitem.flags &= ~(ITEM_FLAG5);
7822 6823 tempitem.misc3 = 0;
7823 6823 tempitem.misc4 = 0;
7824 6823 tempitem.misc5 = 0;
7825 6823 tempitem.misc6 = 0;
7826 6823 tempitem.misc7 = 0;
7827 6823 tempitem.misc8 = 0;
7828 6823 tempitem.misc9 = 0;
7829 6823 tempitem.misc10 = 0;
7830 6823 tempitem.wpn4 = 0;
7831 6823 tempitem.wpn5 = 0;
7832 6823 tempitem.wpn6 = 0;
7833 6823 tempitem.wpn7 = 0;
7834 6823 tempitem.wpn8 = 0;
7835 6823 tempitem.wpn9 = 0;
7836 6823 tempitem.wpn10 = 0;
7837 6823 break;
7838 }
7839 case itype_brang:
7840 {
7841 250 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7842 250 tempitem.misc2 = 0;
7843 250 tempitem.misc5 = 0;
7844 250 tempitem.misc6 = 0;
7845 250 tempitem.misc7 = 0;
7846 250 tempitem.misc8 = 0;
7847 250 tempitem.misc9 = 0;
7848 250 tempitem.misc10 = 0;
7849 250 tempitem.wpn4 = 0;
7850 250 tempitem.wpn5 = 0;
7851 250 tempitem.wpn6 = 0;
7852 250 tempitem.wpn7 = 0;
7853 250 tempitem.wpn8 = 0;
7854 250 tempitem.wpn9 = 0;
7855 250 tempitem.wpn10 = 0;
7856 250 break;
7857 }
7858 case itype_arrow:
7859 {
7860 249 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7861 249 tempitem.misc2 = 0;
7862 249 tempitem.misc3 = 0;
7863 249 tempitem.misc4 = 0;
7864 249 tempitem.misc5 = 0;
7865 249 tempitem.misc6 = 0;
7866 249 tempitem.misc7 = 0;
7867 249 tempitem.misc8 = 0;
7868 249 tempitem.misc9 = 0;
7869 249 tempitem.misc10 = 0;
7870 249 tempitem.wpn4 = 0;
7871 249 tempitem.wpn5 = 0;
7872 249 tempitem.wpn6 = 0;
7873 249 tempitem.wpn7 = 0;
7874 249 tempitem.wpn8 = 0;
7875 249 tempitem.wpn9 = 0;
7876 249 tempitem.wpn10 = 0;
7877 249 break;
7878 }
7879 case itype_candle:
7880 {
7881 204 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7882 204 tempitem.misc1 = 0;
7883 204 tempitem.misc2 = 0;
7884 204 tempitem.misc3 = 0;
7885 204 tempitem.misc4 = 0;
7886 204 tempitem.misc5 = 0;
7887 204 tempitem.misc6 = 0;
7888 204 tempitem.misc7 = 0;
7889 204 tempitem.misc8 = 0;
7890 204 tempitem.misc9 = 0;
7891 204 tempitem.misc10 = 0;
7892 204 tempitem.wpn4 = 0;
7893 204 tempitem.wpn5 = 0;
7894 204 tempitem.wpn6 = 0;
7895 204 tempitem.wpn7 = 0;
7896 204 tempitem.wpn8 = 0;
7897 204 tempitem.wpn9 = 0;
7898 204 tempitem.wpn10 = 0;
7899 204 break;
7900 }
7901 case itype_whistle:
7902 {
7903 129 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7904 129 tempitem.misc3 = 0;
7905 129 tempitem.misc4 = 0;
7906 129 tempitem.misc5 = 0;
7907 129 tempitem.misc6 = 0;
7908 129 tempitem.misc7 = 0;
7909 129 tempitem.misc8 = 0;
7910 129 tempitem.misc9 = 0;
7911 129 tempitem.misc10 = 0;
7912 129 tempitem.wpn2 = 0;
7913 129 tempitem.wpn3 = 0;
7914 129 tempitem.wpn4 = 0;
7915 129 tempitem.wpn5 = 0;
7916 129 tempitem.wpn6 = 0;
7917 129 tempitem.wpn7 = 0;
7918 129 tempitem.wpn8 = 0;
7919 129 tempitem.wpn9 = 0;
7920 129 tempitem.wpn10 = 0;
7921 129 break;
7922 }
7923 case itype_bait:
7924 {
7925 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7926 84 tempitem.misc2 = 0;
7927 84 tempitem.misc3 = 0;
7928 84 tempitem.misc4 = 0;
7929 84 tempitem.misc5 = 0;
7930 84 tempitem.misc6 = 0;
7931 84 tempitem.misc7 = 0;
7932 84 tempitem.misc8 = 0;
7933 84 tempitem.misc9 = 0;
7934 84 tempitem.misc10 = 0;
7935 84 tempitem.wpn2 = 0;
7936 84 tempitem.wpn3 = 0;
7937 84 tempitem.wpn4 = 0;
7938 84 tempitem.wpn5 = 0;
7939 84 tempitem.wpn6 = 0;
7940 84 tempitem.wpn7 = 0;
7941 84 tempitem.wpn8 = 0;
7942 84 tempitem.wpn9 = 0;
7943 84 tempitem.wpn10 = 0;
7944 84 break;
7945 }
7946 case itype_letter:
7947 {
7948 166 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7949 166 tempitem.misc1 = 0;
7950 166 tempitem.misc2 = 0;
7951 166 tempitem.misc3 = 0;
7952 166 tempitem.misc4 = 0;
7953 166 tempitem.misc5 = 0;
7954 166 tempitem.misc6 = 0;
7955 166 tempitem.misc7 = 0;
7956 166 tempitem.misc8 = 0;
7957 166 tempitem.misc9 = 0;
7958 166 tempitem.misc10 = 0;
7959 166 tempitem.wpn = 0;
7960 166 tempitem.wpn2 = 0;
7961 166 tempitem.wpn3 = 0;
7962 166 tempitem.wpn4 = 0;
7963 166 tempitem.wpn5 = 0;
7964 166 tempitem.wpn6 = 0;
7965 166 tempitem.wpn7 = 0;
7966 166 tempitem.wpn8 = 0;
7967 166 tempitem.wpn9 = 0;
7968 166 tempitem.wpn10 = 0;
7969 166 break;
7970 }
7971 case itype_potion:
7972 {
7973 166 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7974 166 tempitem.misc3 = 0;
7975 166 tempitem.misc4 = 0;
7976 166 tempitem.misc5 = 0;
7977 166 tempitem.misc6 = 0;
7978 166 tempitem.misc7 = 0;
7979 166 tempitem.misc8 = 0;
7980 166 tempitem.misc9 = 0;
7981 166 tempitem.misc10 = 0;
7982 166 tempitem.wpn = 0;
7983 166 tempitem.wpn2 = 0;
7984 166 tempitem.wpn3 = 0;
7985 166 tempitem.wpn4 = 0;
7986 166 tempitem.wpn5 = 0;
7987 166 tempitem.wpn6 = 0;
7988 166 tempitem.wpn7 = 0;
7989 166 tempitem.wpn8 = 0;
7990 166 tempitem.wpn9 = 0;
7991 166 tempitem.wpn10 = 0;
7992 166 break;
7993 }
7994 case itype_wand:
7995 {
7996 98 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
7997 98 tempitem.misc1 = 0;
7998 98 tempitem.misc2 = 0;
7999 98 tempitem.misc3 = 0;
8000 98 tempitem.misc4 = 0;
8001 98 tempitem.misc5 = 0;
8002 98 tempitem.misc6 = 0;
8003 98 tempitem.misc7 = 0;
8004 98 tempitem.misc8 = 0;
8005 98 tempitem.misc9 = 0;
8006 98 tempitem.misc10 = 0;
8007 98 tempitem.wpn4 = 0;
8008 98 tempitem.wpn5 = 0;
8009 98 tempitem.wpn6 = 0;
8010 98 tempitem.wpn7 = 0;
8011 98 tempitem.wpn8 = 0;
8012 98 tempitem.wpn9 = 0;
8013 98 tempitem.wpn10 = 0;
8014 98 break;
8015 }
8016 case itype_ring:
8017 {
8018 275 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8019 275 tempitem.misc2 = 0;
8020 275 tempitem.misc3 = 0;
8021 275 tempitem.misc4 = 0;
8022 275 tempitem.misc5 = 0;
8023 275 tempitem.misc6 = 0;
8024 275 tempitem.misc7 = 0;
8025 275 tempitem.misc8 = 0;
8026 275 tempitem.misc9 = 0;
8027 275 tempitem.misc10 = 0;
8028 275 tempitem.wpn = 0;
8029 275 tempitem.wpn2 = 0;
8030 275 tempitem.wpn3 = 0;
8031 275 tempitem.wpn4 = 0;
8032 275 tempitem.wpn5 = 0;
8033 275 tempitem.wpn6 = 0;
8034 275 tempitem.wpn7 = 0;
8035 275 tempitem.wpn8 = 0;
8036 275 tempitem.wpn9 = 0;
8037 275 tempitem.wpn10 = 0;
8038 275 break;
8039 }
8040 case itype_wallet:
8041 {
8042 249 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8043 249 tempitem.misc3 = 0;
8044 249 tempitem.misc4 = 0;
8045 249 tempitem.misc5 = 0;
8046 249 tempitem.misc6 = 0;
8047 249 tempitem.misc7 = 0;
8048 249 tempitem.misc8 = 0;
8049 249 tempitem.misc9 = 0;
8050 249 tempitem.misc10 = 0;
8051 249 tempitem.wpn = 0;
8052 249 tempitem.wpn2 = 0;
8053 249 tempitem.wpn3 = 0;
8054 249 tempitem.wpn4 = 0;
8055 249 tempitem.wpn5 = 0;
8056 249 tempitem.wpn6 = 0;
8057 249 tempitem.wpn7 = 0;
8058 249 tempitem.wpn8 = 0;
8059 249 tempitem.wpn9 = 0;
8060 249 tempitem.wpn10 = 0;
8061 249 break;
8062 }
8063 case itype_amulet:
8064 {
8065 165 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8066 165 tempitem.misc1 = 0;
8067 165 tempitem.misc2 = 0;
8068 165 tempitem.misc3 = 0;
8069 165 tempitem.misc4 = 0;
8070 165 tempitem.misc5 = 0;
8071 165 tempitem.misc6 = 0;
8072 165 tempitem.misc7 = 0;
8073 165 tempitem.misc8 = 0;
8074 165 tempitem.misc9 = 0;
8075 165 tempitem.misc10 = 0;
8076 165 tempitem.wpn = 0;
8077 165 tempitem.wpn2 = 0;
8078 165 tempitem.wpn3 = 0;
8079 165 tempitem.wpn4 = 0;
8080 165 tempitem.wpn5 = 0;
8081 165 tempitem.wpn6 = 0;
8082 165 tempitem.wpn7 = 0;
8083 165 tempitem.wpn8 = 0;
8084 165 tempitem.wpn9 = 0;
8085 165 tempitem.wpn10 = 0;
8086 165 break;
8087 }
8088 case itype_shield:
8089 {
8090 256 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8091 256 tempitem.misc3 = 0;
8092 256 tempitem.misc4 = 0;
8093 256 tempitem.misc5 = 0;
8094 256 tempitem.misc6 = 0;
8095 256 tempitem.misc7 = 0;
8096 256 tempitem.misc8 = 0;
8097 256 tempitem.misc9 = 0;
8098 256 tempitem.misc10 = 0;
8099 256 tempitem.wpn = 0;
8100 256 tempitem.wpn2 = 0;
8101 256 tempitem.wpn3 = 0;
8102 256 tempitem.wpn4 = 0;
8103 256 tempitem.wpn5 = 0;
8104 256 tempitem.wpn6 = 0;
8105 256 tempitem.wpn7 = 0;
8106 256 tempitem.wpn8 = 0;
8107 256 tempitem.wpn9 = 0;
8108 256 tempitem.wpn10 = 0;
8109 256 break;
8110 }
8111 case itype_bow:
8112 {
8113 166 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8114 166 tempitem.misc1 = 0;
8115 166 tempitem.misc2 = 0;
8116 166 tempitem.misc3 = 0;
8117 166 tempitem.misc4 = 0;
8118 166 tempitem.misc5 = 0;
8119 166 tempitem.misc6 = 0;
8120 166 tempitem.misc7 = 0;
8121 166 tempitem.misc8 = 0;
8122 166 tempitem.misc9 = 0;
8123 166 tempitem.misc10 = 0;
8124 166 tempitem.wpn = 0;
8125 166 tempitem.wpn2 = 0;
8126 166 tempitem.wpn3 = 0;
8127 166 tempitem.wpn4 = 0;
8128 166 tempitem.wpn5 = 0;
8129 166 tempitem.wpn6 = 0;
8130 166 tempitem.wpn7 = 0;
8131 166 tempitem.wpn8 = 0;
8132 166 tempitem.wpn9 = 0;
8133 166 tempitem.wpn10 = 0;
8134 166 break;
8135 }
8136 case itype_raft:
8137 {
8138 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8139 83 tempitem.misc1 = 0;
8140 83 tempitem.misc2 = 0;
8141 83 tempitem.misc3 = 0;
8142 83 tempitem.misc4 = 0;
8143 83 tempitem.misc5 = 0;
8144 83 tempitem.misc6 = 0;
8145 83 tempitem.misc7 = 0;
8146 83 tempitem.misc8 = 0;
8147 83 tempitem.misc9 = 0;
8148 83 tempitem.misc10 = 0;
8149 83 tempitem.wpn = 0;
8150 83 tempitem.wpn2 = 0;
8151 83 tempitem.wpn3 = 0;
8152 83 tempitem.wpn4 = 0;
8153 83 tempitem.wpn5 = 0;
8154 83 tempitem.wpn6 = 0;
8155 83 tempitem.wpn7 = 0;
8156 83 tempitem.wpn8 = 0;
8157 83 tempitem.wpn9 = 0;
8158 83 tempitem.wpn10 = 0;
8159 83 break;
8160 }
8161 case itype_ladder:
8162 {
8163 166 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8164 166 tempitem.misc1 = 0;
8165 166 tempitem.misc2 = 0;
8166 166 tempitem.misc3 = 0;
8167 166 tempitem.misc4 = 0;
8168 166 tempitem.misc5 = 0;
8169 166 tempitem.misc6 = 0;
8170 166 tempitem.misc7 = 0;
8171 166 tempitem.misc8 = 0;
8172 166 tempitem.misc9 = 0;
8173 166 tempitem.misc10 = 0;
8174 166 tempitem.wpn = 0;
8175 166 tempitem.wpn2 = 0;
8176 166 tempitem.wpn3 = 0;
8177 166 tempitem.wpn4 = 0;
8178 166 tempitem.wpn5 = 0;
8179 166 tempitem.wpn6 = 0;
8180 166 tempitem.wpn7 = 0;
8181 166 tempitem.wpn8 = 0;
8182 166 tempitem.wpn9 = 0;
8183 166 tempitem.wpn10 = 0;
8184 166 break;
8185 }
8186 case itype_book:
8187 {
8188 98 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8189 98 tempitem.misc1 = 0;
8190 98 tempitem.misc2 = 0;
8191 98 tempitem.misc3 = 0;
8192 98 tempitem.misc4 = 0;
8193 98 tempitem.misc5 = 0;
8194 98 tempitem.misc6 = 0;
8195 98 tempitem.misc7 = 0;
8196 98 tempitem.misc8 = 0;
8197 98 tempitem.misc9 = 0;
8198 98 tempitem.misc10 = 0;
8199 98 tempitem.wpn3 = 0;
8200 98 tempitem.wpn4 = 0;
8201 98 tempitem.wpn5 = 0;
8202 98 tempitem.wpn6 = 0;
8203 98 tempitem.wpn7 = 0;
8204 98 tempitem.wpn8 = 0;
8205 98 tempitem.wpn9 = 0;
8206 98 tempitem.wpn10 = 0;
8207 98 break;
8208 }
8209 case itype_magickey:
8210 {
8211 83 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8212 83 tempitem.misc1 = 0;
8213 83 tempitem.misc2 = 0;
8214 83 tempitem.misc3 = 0;
8215 83 tempitem.misc4 = 0;
8216 83 tempitem.misc5 = 0;
8217 83 tempitem.misc6 = 0;
8218 83 tempitem.misc7 = 0;
8219 83 tempitem.misc8 = 0;
8220 83 tempitem.misc9 = 0;
8221 83 tempitem.misc10 = 0;
8222 83 tempitem.wpn = 0;
8223 83 tempitem.wpn2 = 0;
8224 83 tempitem.wpn3 = 0;
8225 83 tempitem.wpn4 = 0;
8226 83 tempitem.wpn5 = 0;
8227 83 tempitem.wpn6 = 0;
8228 83 tempitem.wpn7 = 0;
8229 83 tempitem.wpn8 = 0;
8230 83 tempitem.wpn9 = 0;
8231 83 tempitem.wpn10 = 0;
8232 83 break;
8233 }
8234 case itype_bracelet:
8235 {
8236 252 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8237 252 tempitem.misc1 = 0;
8238 252 tempitem.misc2 = 0;
8239 252 tempitem.misc3 = 0;
8240 252 tempitem.misc4 = 0;
8241 252 tempitem.misc5 = 0;
8242 252 tempitem.misc6 = 0;
8243 252 tempitem.misc7 = 0;
8244 252 tempitem.misc8 = 0;
8245 252 tempitem.misc9 = 0;
8246 252 tempitem.misc10 = 0;
8247 252 tempitem.wpn = 0;
8248 252 tempitem.wpn2 = 0;
8249 252 tempitem.wpn3 = 0;
8250 252 tempitem.wpn4 = 0;
8251 252 tempitem.wpn5 = 0;
8252 252 tempitem.wpn6 = 0;
8253 252 tempitem.wpn7 = 0;
8254 252 tempitem.wpn8 = 0;
8255 252 tempitem.wpn9 = 0;
8256 252 tempitem.wpn10 = 0;
8257 252 break;
8258 }
8259 case itype_flippers:
8260 {
8261 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8262 84 tempitem.misc1 = 0;
8263 84 tempitem.misc2 = 0;
8264 84 tempitem.misc3 = 0;
8265 84 tempitem.misc4 = 0;
8266 84 tempitem.misc5 = 0;
8267 84 tempitem.misc6 = 0;
8268 84 tempitem.misc7 = 0;
8269 84 tempitem.misc8 = 0;
8270 84 tempitem.misc9 = 0;
8271 84 tempitem.misc10 = 0;
8272 84 tempitem.wpn = 0;
8273 84 tempitem.wpn2 = 0;
8274 84 tempitem.wpn3 = 0;
8275 84 tempitem.wpn4 = 0;
8276 84 tempitem.wpn5 = 0;
8277 84 tempitem.wpn6 = 0;
8278 84 tempitem.wpn7 = 0;
8279 84 tempitem.wpn8 = 0;
8280 84 tempitem.wpn9 = 0;
8281 84 tempitem.wpn10 = 0;
8282 84 break;
8283 }
8284 case itype_boots:
8285 {
8286 85 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8287 85 tempitem.misc1 = 0;
8288 85 tempitem.misc2 = 0;
8289 85 tempitem.misc3 = 0;
8290 85 tempitem.misc4 = 0;
8291 85 tempitem.misc5 = 0;
8292 85 tempitem.misc6 = 0;
8293 85 tempitem.misc7 = 0;
8294 85 tempitem.misc8 = 0;
8295 85 tempitem.misc9 = 0;
8296 85 tempitem.misc10 = 0;
8297 85 tempitem.wpn = 0;
8298 85 tempitem.wpn2 = 0;
8299 85 tempitem.wpn3 = 0;
8300 85 tempitem.wpn4 = 0;
8301 85 tempitem.wpn5 = 0;
8302 85 tempitem.wpn6 = 0;
8303 85 tempitem.wpn7 = 0;
8304 85 tempitem.wpn8 = 0;
8305 85 tempitem.wpn9 = 0;
8306 85 tempitem.wpn10 = 0;
8307 85 break;
8308 }
8309 case itype_hookshot:
8310 {
8311 166 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8312 166 tempitem.misc5 = 0;
8313 166 tempitem.misc6 = 0;
8314 166 tempitem.misc7 = 0;
8315 166 tempitem.misc8 = 0;
8316 166 tempitem.misc9 = 0;
8317 166 tempitem.misc10 = 0;
8318 166 tempitem.wpn5 = 0;
8319 166 tempitem.wpn6 = 0;
8320 166 tempitem.wpn7 = 0;
8321 166 tempitem.wpn8 = 0;
8322 166 tempitem.wpn9 = 0;
8323 166 tempitem.wpn10 = 0;
8324 166 break;
8325 }
8326 case itype_lens:
8327 {
8328 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8329 83 tempitem.misc2 = 0;
8330 83 tempitem.misc3 = 0;
8331 83 tempitem.misc4 = 0;
8332 83 tempitem.misc5 = 0;
8333 83 tempitem.misc6 = 0;
8334 83 tempitem.misc7 = 0;
8335 83 tempitem.misc8 = 0;
8336 83 tempitem.misc9 = 0;
8337 83 tempitem.misc10 = 0;
8338 83 tempitem.wpn = 0;
8339 83 tempitem.wpn2 = 0;
8340 83 tempitem.wpn3 = 0;
8341 83 tempitem.wpn4 = 0;
8342 83 tempitem.wpn5 = 0;
8343 83 tempitem.wpn6 = 0;
8344 83 tempitem.wpn7 = 0;
8345 83 tempitem.wpn8 = 0;
8346 83 tempitem.wpn9 = 0;
8347 83 tempitem.wpn10 = 0;
8348 83 break;
8349 }
8350 case itype_hammer:
8351 {
8352 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8353 84 tempitem.misc1 = 0;
8354 84 tempitem.misc2 = 0;
8355 84 tempitem.misc3 = 0;
8356 84 tempitem.misc4 = 0;
8357 84 tempitem.misc5 = 0;
8358 84 tempitem.misc6 = 0;
8359 84 tempitem.misc7 = 0;
8360 84 tempitem.misc8 = 0;
8361 84 tempitem.misc9 = 0;
8362 84 tempitem.misc10 = 0;
8363 84 tempitem.wpn3 = 0;
8364 84 tempitem.wpn4 = 0;
8365 84 tempitem.wpn5 = 0;
8366 84 tempitem.wpn6 = 0;
8367 84 tempitem.wpn7 = 0;
8368 84 tempitem.wpn8 = 0;
8369 84 tempitem.wpn9 = 0;
8370 84 tempitem.wpn10 = 0;
8371 84 break;
8372 }
8373 case itype_divinefire:
8374 {
8375 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8376 83 tempitem.misc3 = 0;
8377 83 tempitem.misc4 = 0;
8378 83 tempitem.misc5 = 0;
8379 83 tempitem.misc6 = 0;
8380 83 tempitem.misc7 = 0;
8381 83 tempitem.misc8 = 0;
8382 83 tempitem.misc9 = 0;
8383 83 tempitem.misc10 = 0;
8384 83 tempitem.wpn6 = 0;
8385 83 tempitem.wpn7 = 0;
8386 83 tempitem.wpn8 = 0;
8387 83 tempitem.wpn9 = 0;
8388 83 tempitem.wpn10 = 0;
8389 83 break;
8390 }
8391 case itype_divineescape:
8392 {
8393 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8394 83 tempitem.misc2 = 0;
8395 83 tempitem.misc3 = 0;
8396 83 tempitem.misc4 = 0;
8397 83 tempitem.misc5 = 0;
8398 83 tempitem.misc6 = 0;
8399 83 tempitem.misc7 = 0;
8400 83 tempitem.misc8 = 0;
8401 83 tempitem.misc9 = 0;
8402 83 tempitem.misc10 = 0;
8403 83 tempitem.wpn = 0;
8404 83 tempitem.wpn2 = 0;
8405 83 tempitem.wpn3 = 0;
8406 83 tempitem.wpn4 = 0;
8407 83 tempitem.wpn5 = 0;
8408 83 tempitem.wpn6 = 0;
8409 83 tempitem.wpn7 = 0;
8410 83 tempitem.wpn8 = 0;
8411 83 tempitem.wpn9 = 0;
8412 83 tempitem.wpn10 = 0;
8413 83 break;
8414 }
8415 case itype_divineprotection:
8416 {
8417 83 tempitem.flags &= ~ (ITEM_FLAG5);
8418 83 tempitem.misc2 = 0;
8419 83 tempitem.misc3 = 0;
8420 83 tempitem.misc4 = 0;
8421 83 tempitem.misc5 = 0;
8422 83 tempitem.misc6 = 0;
8423 83 tempitem.misc7 = 0;
8424 83 tempitem.misc8 = 0;
8425 83 tempitem.misc9 = 0;
8426 83 tempitem.misc10 = 0;
8427 83 break;
8428 }
8429 case itype_bomb:
8430 {
8431 98 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8432 98 tempitem.misc4 = 0;
8433 98 tempitem.misc5 = 0;
8434 98 tempitem.misc6 = 0;
8435 98 tempitem.misc7 = 0;
8436 98 tempitem.misc8 = 0;
8437 98 tempitem.misc9 = 0;
8438 98 tempitem.misc10 = 0;
8439 98 tempitem.wpn3 = 0;
8440 98 tempitem.wpn4 = 0;
8441 98 tempitem.wpn5 = 0;
8442 98 tempitem.wpn6 = 0;
8443 98 tempitem.wpn7 = 0;
8444 98 tempitem.wpn8 = 0;
8445 98 tempitem.wpn9 = 0;
8446 98 tempitem.wpn10 = 0;
8447 98 break;
8448 }
8449 case itype_sbomb:
8450 {
8451 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8452 83 tempitem.misc4 = 0;
8453 83 tempitem.misc5 = 0;
8454 83 tempitem.misc6 = 0;
8455 83 tempitem.misc7 = 0;
8456 83 tempitem.misc8 = 0;
8457 83 tempitem.misc9 = 0;
8458 83 tempitem.misc10 = 0;
8459 83 tempitem.wpn3 = 0;
8460 83 tempitem.wpn4 = 0;
8461 83 tempitem.wpn5 = 0;
8462 83 tempitem.wpn6 = 0;
8463 83 tempitem.wpn7 = 0;
8464 83 tempitem.wpn8 = 0;
8465 83 tempitem.wpn9 = 0;
8466 83 tempitem.wpn10 = 0;
8467 83 break;
8468 }
8469 case itype_clock:
8470 {
8471 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8472 84 tempitem.misc2 = 0;
8473 84 tempitem.misc3 = 0;
8474 84 tempitem.misc4 = 0;
8475 84 tempitem.misc5 = 0;
8476 84 tempitem.misc6 = 0;
8477 84 tempitem.misc7 = 0;
8478 84 tempitem.misc8 = 0;
8479 84 tempitem.misc9 = 0;
8480 84 tempitem.misc10 = 0;
8481 84 tempitem.wpn = 0;
8482 84 tempitem.wpn2 = 0;
8483 84 tempitem.wpn3 = 0;
8484 84 tempitem.wpn4 = 0;
8485 84 tempitem.wpn5 = 0;
8486 84 tempitem.wpn6 = 0;
8487 84 tempitem.wpn7 = 0;
8488 84 tempitem.wpn8 = 0;
8489 84 tempitem.wpn9 = 0;
8490 84 tempitem.wpn10 = 0;
8491 84 break;
8492 }
8493 case itype_key:
8494 {
8495 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8496 83 tempitem.misc1 = 0;
8497 83 tempitem.misc2 = 0;
8498 83 tempitem.misc3 = 0;
8499 83 tempitem.misc4 = 0;
8500 83 tempitem.misc5 = 0;
8501 83 tempitem.misc6 = 0;
8502 83 tempitem.misc7 = 0;
8503 83 tempitem.misc8 = 0;
8504 83 tempitem.misc9 = 0;
8505 83 tempitem.misc10 = 0;
8506 83 tempitem.wpn = 0;
8507 83 tempitem.wpn2 = 0;
8508 83 tempitem.wpn3 = 0;
8509 83 tempitem.wpn4 = 0;
8510 83 tempitem.wpn5 = 0;
8511 83 tempitem.wpn6 = 0;
8512 83 tempitem.wpn7 = 0;
8513 83 tempitem.wpn8 = 0;
8514 83 tempitem.wpn9 = 0;
8515 83 tempitem.wpn10 = 0;
8516 83 break;
8517 }
8518 case itype_magiccontainer:
8519 {
8520 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8521 84 tempitem.misc1 = 0;
8522 84 tempitem.misc2 = 0;
8523 84 tempitem.misc3 = 0;
8524 84 tempitem.misc4 = 0;
8525 84 tempitem.misc5 = 0;
8526 84 tempitem.misc6 = 0;
8527 84 tempitem.misc7 = 0;
8528 84 tempitem.misc8 = 0;
8529 84 tempitem.misc9 = 0;
8530 84 tempitem.misc10 = 0;
8531 84 tempitem.wpn = 0;
8532 84 tempitem.wpn2 = 0;
8533 84 tempitem.wpn3 = 0;
8534 84 tempitem.wpn4 = 0;
8535 84 tempitem.wpn5 = 0;
8536 84 tempitem.wpn6 = 0;
8537 84 tempitem.wpn7 = 0;
8538 84 tempitem.wpn8 = 0;
8539 84 tempitem.wpn9 = 0;
8540 84 tempitem.wpn10 = 0;
8541 84 break;
8542 }
8543 case itype_triforcepiece:
8544 {
8545 166 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8546 166 tempitem.misc3 = 0;
8547 166 tempitem.misc4 = 0;
8548 166 tempitem.misc5 = 0;
8549 166 tempitem.misc6 = 0;
8550 166 tempitem.misc7 = 0;
8551 166 tempitem.misc8 = 0;
8552 166 tempitem.misc9 = 0;
8553 166 tempitem.misc10 = 0;
8554 166 tempitem.wpn = 0;
8555 166 tempitem.wpn2 = 0;
8556 166 tempitem.wpn3 = 0;
8557 166 tempitem.wpn4 = 0;
8558 166 tempitem.wpn5 = 0;
8559 166 tempitem.wpn6 = 0;
8560 166 tempitem.wpn7 = 0;
8561 166 tempitem.wpn8 = 0;
8562 166 tempitem.wpn9 = 0;
8563 166 tempitem.wpn10 = 0;
8564 166 break;
8565 }
8566 case itype_map: case itype_compass: case itype_bosskey:
8567 {
8568 250 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8569 250 tempitem.misc1 = 0;
8570 250 tempitem.misc2 = 0;
8571 250 tempitem.misc3 = 0;
8572 250 tempitem.misc4 = 0;
8573 250 tempitem.misc5 = 0;
8574 250 tempitem.misc6 = 0;
8575 250 tempitem.misc7 = 0;
8576 250 tempitem.misc8 = 0;
8577 250 tempitem.misc9 = 0;
8578 250 tempitem.misc10 = 0;
8579 250 tempitem.wpn = 0;
8580 250 tempitem.wpn2 = 0;
8581 250 tempitem.wpn3 = 0;
8582 250 tempitem.wpn4 = 0;
8583 250 tempitem.wpn5 = 0;
8584 250 tempitem.wpn6 = 0;
8585 250 tempitem.wpn7 = 0;
8586 250 tempitem.wpn8 = 0;
8587 250 tempitem.wpn9 = 0;
8588 250 tempitem.wpn10 = 0;
8589 250 break;
8590 }
8591 case itype_quiver:
8592 {
8593 332 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8594 332 tempitem.misc3 = 0;
8595 332 tempitem.misc4 = 0;
8596 332 tempitem.misc5 = 0;
8597 332 tempitem.misc6 = 0;
8598 332 tempitem.misc7 = 0;
8599 332 tempitem.misc8 = 0;
8600 332 tempitem.misc9 = 0;
8601 332 tempitem.misc10 = 0;
8602 332 tempitem.wpn = 0;
8603 332 tempitem.wpn2 = 0;
8604 332 tempitem.wpn3 = 0;
8605 332 tempitem.wpn4 = 0;
8606 332 tempitem.wpn5 = 0;
8607 332 tempitem.wpn6 = 0;
8608 332 tempitem.wpn7 = 0;
8609 332 tempitem.wpn8 = 0;
8610 332 tempitem.wpn9 = 0;
8611 332 tempitem.wpn10 = 0;
8612 332 break;
8613 }
8614 case itype_lkey:
8615 {
8616 85 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8617 85 tempitem.misc1 = 0;
8618 85 tempitem.misc2 = 0;
8619 85 tempitem.misc3 = 0;
8620 85 tempitem.misc4 = 0;
8621 85 tempitem.misc5 = 0;
8622 85 tempitem.misc6 = 0;
8623 85 tempitem.misc7 = 0;
8624 85 tempitem.misc8 = 0;
8625 85 tempitem.misc9 = 0;
8626 85 tempitem.misc10 = 0;
8627 85 tempitem.wpn = 0;
8628 85 tempitem.wpn2 = 0;
8629 85 tempitem.wpn3 = 0;
8630 85 tempitem.wpn4 = 0;
8631 85 tempitem.wpn5 = 0;
8632 85 tempitem.wpn6 = 0;
8633 85 tempitem.wpn7 = 0;
8634 85 tempitem.wpn8 = 0;
8635 85 tempitem.wpn9 = 0;
8636 85 tempitem.wpn10 = 0;
8637 85 break;
8638 }
8639 case itype_cbyrna:
8640 {
8641 83 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8642 83 tempitem.misc4 = 0;
8643 83 tempitem.misc5 = 0;
8644 83 tempitem.misc6 = 0;
8645 83 tempitem.misc7 = 0;
8646 83 tempitem.misc8 = 0;
8647 83 tempitem.misc9 = 0;
8648 83 tempitem.misc10 = 0;
8649 83 tempitem.wpn6 = 0;
8650 83 tempitem.wpn7 = 0;
8651 83 tempitem.wpn8 = 0;
8652 83 tempitem.wpn9 = 0;
8653 83 tempitem.wpn10 = 0;
8654 83 break;
8655 }
8656 case itype_rupee: case itype_arrowammo:
8657 {
8658 1035 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8659 1035 tempitem.misc1 = 0;
8660 1035 tempitem.misc2 = 0;
8661 1035 tempitem.misc3 = 0;
8662 1035 tempitem.misc4 = 0;
8663 1035 tempitem.misc5 = 0;
8664 1035 tempitem.misc6 = 0;
8665 1035 tempitem.misc7 = 0;
8666 1035 tempitem.misc8 = 0;
8667 1035 tempitem.misc9 = 0;
8668 1035 tempitem.misc10 = 0;
8669 1035 tempitem.wpn = 0;
8670 1035 tempitem.wpn2 = 0;
8671 1035 tempitem.wpn3 = 0;
8672 1035 tempitem.wpn4 = 0;
8673 1035 tempitem.wpn5 = 0;
8674 1035 tempitem.wpn6 = 0;
8675 1035 tempitem.wpn7 = 0;
8676 1035 tempitem.wpn8 = 0;
8677 1035 tempitem.wpn9 = 0;
8678 1035 tempitem.wpn10 = 0;
8679 1035 break;
8680 }
8681 case itype_fairy:
8682 {
8683 150 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8684 150 tempitem.misc4 = 0;
8685 150 tempitem.misc5 = 0;
8686 150 tempitem.misc6 = 0;
8687 150 tempitem.misc7 = 0;
8688 150 tempitem.misc8 = 0;
8689 150 tempitem.misc9 = 0;
8690 150 tempitem.misc10 = 0;
8691 150 tempitem.wpn = 0;
8692 150 tempitem.wpn2 = 0;
8693 150 tempitem.wpn3 = 0;
8694 150 tempitem.wpn4 = 0;
8695 150 tempitem.wpn5 = 0;
8696 150 tempitem.wpn6 = 0;
8697 150 tempitem.wpn7 = 0;
8698 150 tempitem.wpn8 = 0;
8699 150 tempitem.wpn9 = 0;
8700 150 tempitem.wpn10 = 0;
8701 150 break;
8702 }
8703 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8704 {
8705 892 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8706 892 tempitem.misc1 = 0;
8707 892 tempitem.misc2 = 0;
8708 892 tempitem.misc3 = 0;
8709 892 tempitem.misc4 = 0;
8710 892 tempitem.misc5 = 0;
8711 892 tempitem.misc6 = 0;
8712 892 tempitem.misc7 = 0;
8713 892 tempitem.misc8 = 0;
8714 892 tempitem.misc9 = 0;
8715 892 tempitem.misc10 = 0;
8716 892 tempitem.wpn = 0;
8717 892 tempitem.wpn2 = 0;
8718 892 tempitem.wpn3 = 0;
8719 892 tempitem.wpn4 = 0;
8720 892 tempitem.wpn5 = 0;
8721 892 tempitem.wpn6 = 0;
8722 892 tempitem.wpn7 = 0;
8723 892 tempitem.wpn8 = 0;
8724 892 tempitem.wpn9 = 0;
8725 892 tempitem.wpn10 = 0;
8726 892 break;
8727 }
8728 case itype_bombbag:
8729 {
8730 332 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8731 332 tempitem.misc3 = 0;
8732 332 tempitem.misc4 = 0;
8733 332 tempitem.misc5 = 0;
8734 332 tempitem.misc6 = 0;
8735 332 tempitem.misc7 = 0;
8736 332 tempitem.misc8 = 0;
8737 332 tempitem.misc9 = 0;
8738 332 tempitem.misc10 = 0;
8739 332 tempitem.wpn = 0;
8740 332 tempitem.wpn2 = 0;
8741 332 tempitem.wpn3 = 0;
8742 332 tempitem.wpn4 = 0;
8743 332 tempitem.wpn5 = 0;
8744 332 tempitem.wpn6 = 0;
8745 332 tempitem.wpn7 = 0;
8746 332 tempitem.wpn8 = 0;
8747 332 tempitem.wpn9 = 0;
8748 332 tempitem.wpn10 = 0;
8749 332 break;
8750 }
8751 case itype_rocs:
8752 {
8753 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8754 83 tempitem.misc1 = 0;
8755 83 tempitem.misc2 = 0;
8756 83 tempitem.misc3 = 0;
8757 83 tempitem.misc4 = 0;
8758 83 tempitem.misc5 = 0;
8759 83 tempitem.misc6 = 0;
8760 83 tempitem.misc7 = 0;
8761 83 tempitem.misc8 = 0;
8762 83 tempitem.misc9 = 0;
8763 83 tempitem.misc10 = 0;
8764 83 tempitem.wpn = 0;
8765 83 tempitem.wpn2 = 0;
8766 83 tempitem.wpn3 = 0;
8767 83 tempitem.wpn4 = 0;
8768 83 tempitem.wpn5 = 0;
8769 83 tempitem.wpn6 = 0;
8770 83 tempitem.wpn7 = 0;
8771 83 tempitem.wpn8 = 0;
8772 83 tempitem.wpn9 = 0;
8773 83 tempitem.wpn10 = 0;
8774 83 break;
8775 }
8776 case itype_hoverboots:
8777 {
8778 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8779 83 tempitem.misc2 = 0;
8780 83 tempitem.misc3 = 0;
8781 83 tempitem.misc4 = 0;
8782 83 tempitem.misc5 = 0;
8783 83 tempitem.misc6 = 0;
8784 83 tempitem.misc7 = 0;
8785 83 tempitem.misc8 = 0;
8786 83 tempitem.misc9 = 0;
8787 83 tempitem.misc10 = 0;
8788 83 tempitem.wpn2 = 0;
8789 83 tempitem.wpn3 = 0;
8790 83 tempitem.wpn4 = 0;
8791 83 tempitem.wpn5 = 0;
8792 83 tempitem.wpn6 = 0;
8793 83 tempitem.wpn7 = 0;
8794 83 tempitem.wpn8 = 0;
8795 83 tempitem.wpn9 = 0;
8796 83 tempitem.wpn10 = 0;
8797 83 break;
8798 }
8799 case itype_spinscroll:
8800 {
8801 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8802 83 tempitem.misc2 = 0;
8803 83 tempitem.misc3 = 0;
8804 83 tempitem.misc4 = 0;
8805 83 tempitem.misc5 = 0;
8806 83 tempitem.misc6 = 0;
8807 83 tempitem.misc7 = 0;
8808 83 tempitem.misc8 = 0;
8809 83 tempitem.misc9 = 0;
8810 83 tempitem.misc10 = 0;
8811 83 tempitem.wpn = 0;
8812 83 tempitem.wpn2 = 0;
8813 83 tempitem.wpn3 = 0;
8814 83 tempitem.wpn4 = 0;
8815 83 tempitem.wpn5 = 0;
8816 83 tempitem.wpn6 = 0;
8817 83 tempitem.wpn7 = 0;
8818 83 tempitem.wpn8 = 0;
8819 83 tempitem.wpn9 = 0;
8820 83 tempitem.wpn10 = 0;
8821 83 break;
8822 }
8823 case itype_crossscroll:
8824 {
8825 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8826 83 tempitem.misc1 = 0;
8827 83 tempitem.misc2 = 0;
8828 83 tempitem.misc3 = 0;
8829 83 tempitem.misc4 = 0;
8830 83 tempitem.misc5 = 0;
8831 83 tempitem.misc6 = 0;
8832 83 tempitem.misc7 = 0;
8833 83 tempitem.misc8 = 0;
8834 83 tempitem.misc9 = 0;
8835 83 tempitem.misc10 = 0;
8836 83 tempitem.wpn = 0;
8837 83 tempitem.wpn2 = 0;
8838 83 tempitem.wpn3 = 0;
8839 83 tempitem.wpn4 = 0;
8840 83 tempitem.wpn5 = 0;
8841 83 tempitem.wpn6 = 0;
8842 83 tempitem.wpn7 = 0;
8843 83 tempitem.wpn8 = 0;
8844 83 tempitem.wpn9 = 0;
8845 83 tempitem.wpn10 = 0;
8846 83 break;
8847 }
8848 case itype_quakescroll:
8849 {
8850 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8851 83 tempitem.misc3 = 0;
8852 83 tempitem.misc4 = 0;
8853 83 tempitem.misc5 = 0;
8854 83 tempitem.misc6 = 0;
8855 83 tempitem.misc7 = 0;
8856 83 tempitem.misc8 = 0;
8857 83 tempitem.misc9 = 0;
8858 83 tempitem.misc10 = 0;
8859 83 tempitem.wpn = 0;
8860 83 tempitem.wpn2 = 0;
8861 83 tempitem.wpn3 = 0;
8862 83 tempitem.wpn4 = 0;
8863 83 tempitem.wpn5 = 0;
8864 83 tempitem.wpn6 = 0;
8865 83 tempitem.wpn7 = 0;
8866 83 tempitem.wpn8 = 0;
8867 83 tempitem.wpn9 = 0;
8868 83 tempitem.wpn10 = 0;
8869 83 break;
8870 }
8871 case itype_whispring:
8872 {
8873 167 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8874 167 tempitem.misc2 = 0;
8875 167 tempitem.misc3 = 0;
8876 167 tempitem.misc4 = 0;
8877 167 tempitem.misc5 = 0;
8878 167 tempitem.misc6 = 0;
8879 167 tempitem.misc7 = 0;
8880 167 tempitem.misc8 = 0;
8881 167 tempitem.misc9 = 0;
8882 167 tempitem.misc10 = 0;
8883 167 tempitem.wpn = 0;
8884 167 tempitem.wpn2 = 0;
8885 167 tempitem.wpn3 = 0;
8886 167 tempitem.wpn4 = 0;
8887 167 tempitem.wpn5 = 0;
8888 167 tempitem.wpn6 = 0;
8889 167 tempitem.wpn7 = 0;
8890 167 tempitem.wpn8 = 0;
8891 167 tempitem.wpn9 = 0;
8892 167 tempitem.wpn10 = 0;
8893 167 break;
8894 }
8895 case itype_chargering:
8896 {
8897 166 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8898 166 tempitem.misc3 = 0;
8899 166 tempitem.misc4 = 0;
8900 166 tempitem.misc5 = 0;
8901 166 tempitem.misc6 = 0;
8902 166 tempitem.misc7 = 0;
8903 166 tempitem.misc8 = 0;
8904 166 tempitem.misc9 = 0;
8905 166 tempitem.misc10 = 0;
8906 166 tempitem.wpn = 0;
8907 166 tempitem.wpn2 = 0;
8908 166 tempitem.wpn3 = 0;
8909 166 tempitem.wpn4 = 0;
8910 166 tempitem.wpn5 = 0;
8911 166 tempitem.wpn6 = 0;
8912 166 tempitem.wpn7 = 0;
8913 166 tempitem.wpn8 = 0;
8914 166 tempitem.wpn9 = 0;
8915 166 tempitem.wpn10 = 0;
8916 166 break;
8917 }
8918 case itype_perilscroll:
8919 {
8920 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8921 83 tempitem.misc2 = 0;
8922 83 tempitem.misc3 = 0;
8923 83 tempitem.misc4 = 0;
8924 83 tempitem.misc5 = 0;
8925 83 tempitem.misc6 = 0;
8926 83 tempitem.misc7 = 0;
8927 83 tempitem.misc8 = 0;
8928 83 tempitem.misc9 = 0;
8929 83 tempitem.misc10 = 0;
8930 83 tempitem.wpn = 0;
8931 83 tempitem.wpn2 = 0;
8932 83 tempitem.wpn3 = 0;
8933 83 tempitem.wpn4 = 0;
8934 83 tempitem.wpn5 = 0;
8935 83 tempitem.wpn6 = 0;
8936 83 tempitem.wpn7 = 0;
8937 83 tempitem.wpn8 = 0;
8938 83 tempitem.wpn9 = 0;
8939 83 tempitem.wpn10 = 0;
8940 83 break;
8941 }
8942 case itype_wealthmedal:
8943 {
8944 250 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8945 250 tempitem.misc2 = 0;
8946 250 tempitem.misc3 = 0;
8947 250 tempitem.misc4 = 0;
8948 250 tempitem.misc5 = 0;
8949 250 tempitem.misc6 = 0;
8950 250 tempitem.misc7 = 0;
8951 250 tempitem.misc8 = 0;
8952 250 tempitem.misc9 = 0;
8953 250 tempitem.misc10 = 0;
8954 250 tempitem.wpn = 0;
8955 250 tempitem.wpn2 = 0;
8956 250 tempitem.wpn3 = 0;
8957 250 tempitem.wpn4 = 0;
8958 250 tempitem.wpn5 = 0;
8959 250 tempitem.wpn6 = 0;
8960 250 tempitem.wpn7 = 0;
8961 250 tempitem.wpn8 = 0;
8962 250 tempitem.wpn9 = 0;
8963 250 tempitem.wpn10 = 0;
8964 250 break;
8965 }
8966 case itype_heartring:
8967 {
8968 251 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8969 251 tempitem.misc3 = 0;
8970 251 tempitem.misc4 = 0;
8971 251 tempitem.misc5 = 0;
8972 251 tempitem.misc6 = 0;
8973 251 tempitem.misc7 = 0;
8974 251 tempitem.misc8 = 0;
8975 251 tempitem.misc9 = 0;
8976 251 tempitem.misc10 = 0;
8977 251 tempitem.wpn = 0;
8978 251 tempitem.wpn2 = 0;
8979 251 tempitem.wpn3 = 0;
8980 251 tempitem.wpn4 = 0;
8981 251 tempitem.wpn5 = 0;
8982 251 tempitem.wpn6 = 0;
8983 251 tempitem.wpn7 = 0;
8984 251 tempitem.wpn8 = 0;
8985 251 tempitem.wpn9 = 0;
8986 251 tempitem.wpn10 = 0;
8987 251 break;
8988 }
8989 case itype_magicring:
8990 {
8991 336 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8992 336 tempitem.misc3 = 0;
8993 336 tempitem.misc4 = 0;
8994 336 tempitem.misc5 = 0;
8995 336 tempitem.misc6 = 0;
8996 336 tempitem.misc7 = 0;
8997 336 tempitem.misc8 = 0;
8998 336 tempitem.misc9 = 0;
8999 336 tempitem.misc10 = 0;
9000 336 tempitem.wpn = 0;
9001 336 tempitem.wpn2 = 0;
9002 336 tempitem.wpn3 = 0;
9003 336 tempitem.wpn4 = 0;
9004 336 tempitem.wpn5 = 0;
9005 336 tempitem.wpn6 = 0;
9006 336 tempitem.wpn7 = 0;
9007 336 tempitem.wpn8 = 0;
9008 336 tempitem.wpn9 = 0;
9009 336 tempitem.wpn10 = 0;
9010 336 break;
9011 }
9012 case itype_spinscroll2:
9013 {
9014 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9015 83 tempitem.misc2 = 0;
9016 83 tempitem.misc3 = 0;
9017 83 tempitem.misc4 = 0;
9018 83 tempitem.misc5 = 0;
9019 83 tempitem.misc6 = 0;
9020 83 tempitem.misc7 = 0;
9021 83 tempitem.misc8 = 0;
9022 83 tempitem.misc9 = 0;
9023 83 tempitem.misc10 = 0;
9024 83 tempitem.wpn = 0;
9025 83 tempitem.wpn2 = 0;
9026 83 tempitem.wpn3 = 0;
9027 83 tempitem.wpn4 = 0;
9028 83 tempitem.wpn5 = 0;
9029 83 tempitem.wpn6 = 0;
9030 83 tempitem.wpn7 = 0;
9031 83 tempitem.wpn8 = 0;
9032 83 tempitem.wpn9 = 0;
9033 83 tempitem.wpn10 = 0;
9034 83 break;
9035 }
9036 case itype_quakescroll2:
9037 {
9038 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9039 83 tempitem.misc3 = 0;
9040 83 tempitem.misc4 = 0;
9041 83 tempitem.misc5 = 0;
9042 83 tempitem.misc6 = 0;
9043 83 tempitem.misc7 = 0;
9044 83 tempitem.misc8 = 0;
9045 83 tempitem.misc9 = 0;
9046 83 tempitem.misc10 = 0;
9047 83 tempitem.wpn = 0;
9048 83 tempitem.wpn2 = 0;
9049 83 tempitem.wpn3 = 0;
9050 83 tempitem.wpn4 = 0;
9051 83 tempitem.wpn5 = 0;
9052 83 tempitem.wpn6 = 0;
9053 83 tempitem.wpn7 = 0;
9054 83 tempitem.wpn8 = 0;
9055 83 tempitem.wpn9 = 0;
9056 83 tempitem.wpn10 = 0;
9057 83 break;
9058 }
9059 case itype_agony:
9060 {
9061 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9062 83 tempitem.misc2 = 0;
9063 83 tempitem.misc3 = 0;
9064 83 tempitem.misc4 = 0;
9065 83 tempitem.misc5 = 0;
9066 83 tempitem.misc6 = 0;
9067 83 tempitem.misc7 = 0;
9068 83 tempitem.misc8 = 0;
9069 83 tempitem.misc9 = 0;
9070 83 tempitem.misc10 = 0;
9071 83 tempitem.wpn = 0;
9072 83 tempitem.wpn2 = 0;
9073 83 tempitem.wpn3 = 0;
9074 83 tempitem.wpn4 = 0;
9075 83 tempitem.wpn5 = 0;
9076 83 tempitem.wpn6 = 0;
9077 83 tempitem.wpn7 = 0;
9078 83 tempitem.wpn8 = 0;
9079 83 tempitem.wpn9 = 0;
9080 83 tempitem.wpn10 = 0;
9081 83 break;
9082 }
9083 case itype_stompboots:
9084 {
9085 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9086 83 tempitem.misc1 = 0;
9087 83 tempitem.misc2 = 0;
9088 83 tempitem.misc3 = 0;
9089 83 tempitem.misc4 = 0;
9090 83 tempitem.misc5 = 0;
9091 83 tempitem.misc6 = 0;
9092 83 tempitem.misc7 = 0;
9093 83 tempitem.misc8 = 0;
9094 83 tempitem.misc9 = 0;
9095 83 tempitem.misc10 = 0;
9096 83 tempitem.wpn = 0;
9097 83 tempitem.wpn2 = 0;
9098 83 tempitem.wpn3 = 0;
9099 83 tempitem.wpn4 = 0;
9100 83 tempitem.wpn5 = 0;
9101 83 tempitem.wpn6 = 0;
9102 83 tempitem.wpn7 = 0;
9103 83 tempitem.wpn8 = 0;
9104 83 tempitem.wpn9 = 0;
9105 83 tempitem.wpn10 = 0;
9106 83 break;
9107 }
9108 case itype_whimsicalring:
9109 {
9110 83 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9111 83 tempitem.misc2 = 0;
9112 83 tempitem.misc3 = 0;
9113 83 tempitem.misc4 = 0;
9114 83 tempitem.misc5 = 0;
9115 83 tempitem.misc6 = 0;
9116 83 tempitem.misc7 = 0;
9117 83 tempitem.misc8 = 0;
9118 83 tempitem.misc9 = 0;
9119 83 tempitem.misc10 = 0;
9120 83 tempitem.wpn = 0;
9121 83 tempitem.wpn2 = 0;
9122 83 tempitem.wpn3 = 0;
9123 83 tempitem.wpn4 = 0;
9124 83 tempitem.wpn5 = 0;
9125 83 tempitem.wpn6 = 0;
9126 83 tempitem.wpn7 = 0;
9127 83 tempitem.wpn8 = 0;
9128 83 tempitem.wpn9 = 0;
9129 83 tempitem.wpn10 = 0;
9130 83 break;
9131 }
9132 case itype_perilring:
9133 {
9134 84 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9135 84 tempitem.misc2 = 0;
9136 84 tempitem.misc3 = 0;
9137 84 tempitem.misc4 = 0;
9138 84 tempitem.misc5 = 0;
9139 84 tempitem.misc6 = 0;
9140 84 tempitem.misc7 = 0;
9141 84 tempitem.misc8 = 0;
9142 84 tempitem.misc9 = 0;
9143 84 tempitem.misc10 = 0;
9144 84 tempitem.wpn = 0;
9145 84 tempitem.wpn2 = 0;
9146 84 tempitem.wpn3 = 0;
9147 84 tempitem.wpn4 = 0;
9148 84 tempitem.wpn5 = 0;
9149 84 tempitem.wpn6 = 0;
9150 84 tempitem.wpn7 = 0;
9151 84 tempitem.wpn8 = 0;
9152 84 tempitem.wpn9 = 0;
9153 84 tempitem.wpn10 = 0;
9154 84 break;
9155 }
9156 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9157 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9158 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9159 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9160 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9161 {
9162 2252 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9163 2252 tempitem.misc1 = 0;
9164 2252 tempitem.misc2 = 0;
9165 2252 tempitem.misc3 = 0;
9166 2252 tempitem.misc4 = 0;
9167 2252 tempitem.misc5 = 0;
9168 2252 tempitem.misc6 = 0;
9169 2252 tempitem.misc7 = 0;
9170 2252 tempitem.misc8 = 0;
9171 2252 tempitem.misc9 = 0;
9172 2252 tempitem.misc10 = 0;
9173 2252 tempitem.wpn = 0;
9174 2252 tempitem.wpn2 = 0;
9175 2252 tempitem.wpn3 = 0;
9176 2252 tempitem.wpn4 = 0;
9177 2252 tempitem.wpn5 = 0;
9178 2252 tempitem.wpn6 = 0;
9179 2252 tempitem.wpn7 = 0;
9180 2252 tempitem.wpn8 = 0;
9181 2252 tempitem.wpn9 = 0;
9182 2252 tempitem.wpn10 = 0;
9183 2252 break;
9184 }
9185 }
9186 21504 }
9187 //Port quest rules to items
9188
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 21504 times.
27904 if( s_version <= 31)
9189 {
9190
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 21406 times.
21504 if(tempitem.family == itype_bomb)
9191 {
9192
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 10 times.
98 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9193 88 else tempitem.flags &= ~ ITEM_FLAG2;
9194 98 }
9195
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 21323 times.
21406 else if(tempitem.family == itype_sbomb)
9196 {
9197
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 73 times.
83 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9198 73 else tempitem.flags &= ~ ITEM_FLAG2;
9199 83 }
9200
9201
2/2
✓ Branch 0 taken 250 times.
✓ Branch 1 taken 21073 times.
21323 else if(tempitem.family == itype_brang)
9202 {
9203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 250 times.
250 if ( get_bit(quest_rules,qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9204 250 else tempitem.flags &= ~ ITEM_FLAG4;
9205 250 }
9206
2/2
✓ Branch 0 taken 20975 times.
✓ Branch 1 taken 98 times.
21073 else if(tempitem.family == itype_wand)
9207 {
9208
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 97 times.
98 if ( get_bit(quest_rules,qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9209 97 else tempitem.flags &= ~ ITEM_FLAG3;
9210 98 }
9211 21504 }
9212
9213 //Port quest rules to items
9214
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 21504 times.
27904 if( s_version <= 37)
9215 {
9216
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 21420 times.
21504 if(tempitem.family == itype_flippers)
9217 {
9218
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if ( (get_bit(quest_rules,qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9219 84 else tempitem.flags &= ~ ITEM_FLAG1;
9220 84 }
9221
2/2
✓ Branch 0 taken 14597 times.
✓ Branch 1 taken 6823 times.
21420 else if(tempitem.family == itype_sword)
9222 {
9223
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6754 times.
6823 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9224 6754 else tempitem.flags &= ~ ITEM_FLAG5;
9225 6823 }
9226
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 14499 times.
14597 else if(tempitem.family == itype_wand)
9227 {
9228
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 95 times.
98 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9229 95 else tempitem.flags &= ~ ITEM_FLAG5;
9230 98 }
9231
4/4
✓ Branch 0 taken 14401 times.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 204 times.
✓ Branch 3 taken 14197 times.
14499 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9232 {
9233 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9234
2/2
✓ Branch 0 taken 233 times.
✓ Branch 1 taken 69 times.
302 if ( (get_bit(quest_rules,qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9235 233 else tempitem.flags &= ~ ITEM_FLAG3;
9236 302 }
9237 21504 }
9238
9239
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 21504 times.
27904 if( s_version < 38)
9240 {
9241
4/4
✓ Branch 0 taken 21254 times.
✓ Branch 1 taken 250 times.
✓ Branch 2 taken 166 times.
✓ Branch 3 taken 21088 times.
21504 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9242 {
9243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 416 times.
416 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9244 416 else tempitem.flags &= ~ITEM_FLAG4;
9245
9246
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 410 times.
416 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9247 410 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9248 416 }
9249
2/2
✓ Branch 0 taken 20839 times.
✓ Branch 1 taken 249 times.
21088 else if(tempitem.family == itype_arrow)
9250 {
9251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
249 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9252 249 else tempitem.flags &= ~ITEM_FLAG4;
9253
9254
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 246 times.
249 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9255 246 else tempitem.flags |= ITEM_FLAG2;
9256 249 }
9257 21504 }
9258
9259
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 21504 times.
27904 if( s_version < 39)
9260 {
9261
6/6
✓ Branch 0 taken 21421 times.
✓ Branch 1 taken 83 times.
✓ Branch 2 taken 21323 times.
✓ Branch 3 taken 98 times.
✓ Branch 4 taken 204 times.
✓ Branch 5 taken 21119 times.
21504 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9262 {
9263
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 373 times.
385 if(get_bit(quest_rules,qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9264 373 else tempitem.flags &= ~ITEM_FLAG5;
9265 385 }
9266
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 20953 times.
21119 else if(tempitem.family == itype_potion)
9267 {
9268
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 156 times.
166 if(get_bit(quest_rules,qr_NONBUBBLEMEDICINE))
9269 {
9270 10 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9271 10 }
9272 else
9273 {
9274 156 tempitem.flags |= ITEM_FLAG3;
9275
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 84 times.
156 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9276 72 else tempitem.flags &= ~ITEM_FLAG4;
9277 }
9278 166 }
9279
2/2
✓ Branch 0 taken 20787 times.
✓ Branch 1 taken 166 times.
20953 else if(tempitem.family == itype_triforcepiece)
9280 {
9281
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 150 times.
166 if(get_bit(quest_rules,qr_NONBUBBLETRIFORCE))
9282 {
9283 16 tempitem.flags |= ITEM_FLAG3;
9284
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 10 times.
16 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9285 10 else tempitem.flags &= ~ITEM_FLAG4;
9286 16 }
9287 else
9288 {
9289 150 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9290 }
9291 166 }
9292 21504 }
9293
9294
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 21504 times.
27904 if( s_version < 40)
9295 {
9296
4/4
✓ Branch 0 taken 21229 times.
✓ Branch 1 taken 275 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 21145 times.
21504 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9297 {
9298
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 316 times.
359 if(get_bit(quest_rules,qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9299 316 else tempitem.flags &= ~ITEM_FLAG1;
9300 359 }
9301
8/8
✓ Branch 0 taken 20941 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 14118 times.
✓ Branch 3 taken 6823 times.
✓ Branch 4 taken 14020 times.
✓ Branch 5 taken 98 times.
✓ Branch 6 taken 83 times.
✓ Branch 7 taken 13937 times.
21145 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9302 {
9303
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 7127 times.
7208 if(get_bit(quest_rules,qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9304 7127 else tempitem.flags &= ~ITEM_FLAG8;
9305 7208 }
9306
6/6
✓ Branch 0 taken 14681 times.
✓ Branch 1 taken 6823 times.
✓ Branch 2 taken 14583 times.
✓ Branch 3 taken 98 times.
✓ Branch 4 taken 84 times.
✓ Branch 5 taken 14499 times.
21504 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9307 {
9308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7005 times.
7005 if(get_bit(quest_rules,qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9309 7005 else tempitem.flags &= ~ITEM_FLAG7;
9310 7005 }
9311
2/2
✓ Branch 0 taken 14416 times.
✓ Branch 1 taken 83 times.
14499 else if(tempitem.family == itype_cbyrna)
9312 {
9313 83 tempitem.flags |= ITEM_FLAG7;
9314 83 }
9315 21504 }
9316
9317
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 21504 times.
27904 if( s_version < 41 )
9318 {
9319
2/2
✓ Branch 0 taken 14681 times.
✓ Branch 1 taken 6823 times.
21504 if(tempitem.family == itype_sword)
9320 {
9321
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6754 times.
6823 if(get_bit(quest_rules,qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9322 6754 else tempitem.flags &= ~ITEM_FLAG9;
9323
9324
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6754 times.
6823 if(get_bit(quest_rules,qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9325 6754 else tempitem.flags &= ~ITEM_FLAG10;
9326 6823 }
9327 21504 }
9328
9329
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 21504 times.
27904 if( s_version < 42 )
9330 {
9331
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 21406 times.
21504 if(tempitem.family == itype_wand)
9332 {
9333
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 1 times.
98 if(get_bit(quest_rules,qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9334 97 else tempitem.flags &= ~ITEM_FLAG3;
9335
9336 98 tempitem.flags &= ~ITEM_FLAG6;
9337 98 }
9338
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 21322 times.
21406 else if(tempitem.family == itype_hammer)
9339 {
9340 84 tempitem.flags &= ~ITEM_FLAG3;
9341 84 }
9342
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 21239 times.
21322 else if(tempitem.family == itype_cbyrna)
9343 {
9344 83 tempitem.flags |= ITEM_FLAG3;
9345
9346 83 tempitem.flags &= ~ITEM_FLAG6;
9347 83 }
9348
2/2
✓ Branch 0 taken 14416 times.
✓ Branch 1 taken 6823 times.
21239 else if(tempitem.family == itype_sword)
9349 {
9350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6823 times.
6823 if(get_bit(quest_rules,qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9351 6823 else tempitem.flags &= ~ITEM_FLAG6;
9352 6823 }
9353 21504 }
9354
9355
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 21504 times.
27904 if( s_version < 43 )
9356 {
9357
2/2
✓ Branch 0 taken 21375 times.
✓ Branch 1 taken 129 times.
21504 if(tempitem.family == itype_whistle)
9358 {
9359
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 3 times.
129 if(get_bit(quest_rules,qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9360 126 else tempitem.flags &= ~ITEM_FLAG3;
9361 129 }
9362 21504 }
9363
9364
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 21504 times.
27904 if( s_version < 45 )
9365 {
9366
2/2
✓ Branch 0 taken 21420 times.
✓ Branch 1 taken 84 times.
21504 if(tempitem.family == itype_flippers)
9367 {
9368 84 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9369 84 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9370 84 }
9371 21504 }
9372
9373
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 21504 times.
27904 if( s_version < 46 )
9374 {
9375
2/2
✓ Branch 0 taken 21421 times.
✓ Branch 1 taken 83 times.
21504 if(tempitem.family == itype_raft)
9376 {
9377 83 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9378 83 }
9379 21504 }
9380
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 21504 times.
27904 if ( s_version < 34 ) //! set the default counter for older quests.
9381 {
9382
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 21430 times.
21504 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9383 {
9384 74 tempitem.cost_counter[0] = 1;
9385 74 }
9386 else
9387 {
9388
2/2
✓ Branch 0 taken 18870 times.
✓ Branch 1 taken 2560 times.
21430 if(get_bit(quest_rules,qr_ENABLEMAGIC))
9389 2560 tempitem.cost_counter[0] = 4;
9390 else
9391 {
9392 18870 tempitem.cost_amount[0] = 0;
9393 18870 tempitem.cost_counter[0] = -1;
9394 }
9395 }
9396 21504 }
9397
9398
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 21504 times.
27904 if ( s_version < 35 ) //new Lens of Truth flags
9399 {
9400
2/2
✓ Branch 0 taken 21421 times.
✓ Branch 1 taken 83 times.
21504 if ( tempitem.family == itype_lens )
9401 {
9402
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 3 times.
83 if ( get_bit(quest_rules,qr_RAFTLENS) )
9403 {
9404 3 tempitem.flags |= ITEM_FLAG4;
9405 3 }
9406
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 45 times.
83 if ( get_bit(quest_rules,qr_LENSHINTS) )
9407 {
9408 45 tempitem.flags |= ITEM_FLAG1;
9409 45 }
9410
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 3 times.
83 if ( get_bit(quest_rules,qr_LENSSEESENEMIES) )
9411 {
9412 3 tempitem.flags |= ITEM_FLAG5;
9413 3 }
9414 83 }
9415 21504 }
9416
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 21504 times.
27904 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9417 {
9418
2/2
✓ Branch 0 taken 172032 times.
✓ Branch 1 taken 21504 times.
193536 for ( int32_t q = 0; q < 8; q++ )
9419 {
9420 172032 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9421 172032 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9422 172032 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9423 172032 tempitem.sprite_initiald[q] = 0;
9424 172032 }
9425
2/2
✓ Branch 0 taken 43008 times.
✓ Branch 1 taken 21504 times.
64512 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9426 21504 tempitem.sprite_script = 0;
9427 21504 }
9428
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 21504 times.
27904 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9429 {
9430 21504 tempitem.pickupflag = 0;
9431 21504 }
9432
9433
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 21504 times.
27904 if( s_version < 51 )
9434 {
9435
2/2
✓ Branch 0 taken 21300 times.
✓ Branch 1 taken 204 times.
21504 if( tempitem.family == itype_candle )
9436 {
9437 204 tempitem.misc4 = 50; //Step speed
9438 204 }
9439 21504 }
9440
9441
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 21504 times.
27904 if( s_version < 52 )
9442 {
9443
2/2
✓ Branch 0 taken 21248 times.
✓ Branch 1 taken 256 times.
21504 if( tempitem.family == itype_shield )
9444 256 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9445 21504 }
9446
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 21504 times.
27904 if(s_version < 53)
9447 {
9448
4/4
✓ Branch 0 taken 21074 times.
✓ Branch 1 taken 249 times.
✓ Branch 2 taken 98 times.
✓ Branch 3 taken 83 times.
21504 switch(tempitem.family)
9449 {
9450 case itype_arrow:
9451 249 tempitem.cost_counter[1] = crARROWS;
9452 249 tempitem.cost_amount[1] = 1;
9453 249 break;
9454 case itype_bomb:
9455 98 tempitem.cost_counter[1] = crBOMBS;
9456 98 tempitem.cost_amount[1] = 1;
9457 98 break;
9458 case itype_sbomb:
9459 83 tempitem.cost_counter[1] = crSBOMBS;
9460 83 tempitem.cost_amount[1] = 1;
9461 83 break;
9462 default:
9463 21074 tempitem.cost_counter[1] = crNONE;
9464 21074 tempitem.cost_amount[1] = 0;
9465 21074 }
9466 21504 tempitem.magiccosttimer[1] = 0;
9467 21504 }
9468
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 25344 times.
27904 if( s_version < 54 )
9469 {
9470
2/2
✓ Branch 0 taken 25244 times.
✓ Branch 1 taken 100 times.
25344 if( tempitem.family == itype_flippers )
9471 100 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9472 25344 }
9473
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 25344 times.
27904 if(s_version < 55)
9474 {
9475
3/3
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 196 times.
✓ Branch 2 taken 24952 times.
25344 switch(tempitem.family)
9476 {
9477 case itype_spinscroll:
9478 case itype_quakescroll:
9479 196 tempitem.usesound2 = WAV_ZN1CHARGE;
9480 196 break;
9481 case itype_spinscroll2:
9482 case itype_quakescroll2:
9483 196 tempitem.usesound2 = WAV_ZN1CHARGE2;
9484 196 break;
9485 }
9486 25344 }
9487
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 25344 times.
27904 if(s_version < 56)
9488 {
9489
4/4
✓ Branch 0 taken 24897 times.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 236 times.
✓ Branch 3 taken 113 times.
25344 switch(tempitem.family)
9490 {
9491 case itype_divinefire:
9492
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 15 times.
98 SETFLAG(tempitem.flags, ITEM_FLAG9, version < 0x255); //Strong Fire
9493
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 89 times.
98 SETFLAG(tempitem.flags, ITEM_FLAG10, version < 0x250); //Magic Fire
9494 98 tempitem.flags |= ITEM_FLAG11; //Divine Fire
9495 98 break;
9496 case itype_candle:
9497
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 121 times.
236 SETFLAG(tempitem.flags, ITEM_FLAG9, tempitem.fam_type > 1); //Strong Fire
9498 236 tempitem.flags &= ~ITEM_FLAG10; //Magic Fire
9499 236 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9500 236 break;
9501 case itype_book:
9502 113 tempitem.flags |= ITEM_FLAG9; //Strong Fire
9503 113 tempitem.flags |= ITEM_FLAG10; //Magic Fire
9504 113 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9505 113 break;
9506 }
9507 25344 }
9508
9509
2/2
✓ Branch 0 taken 26698 times.
✓ Branch 1 taken 1206 times.
27904 if(tempitem.fam_type==0) // Always do this
9510 1206 tempitem.fam_type=1;
9511
9512 27904 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9513 27904 }
9514 109 }
9515
9516 109 return 0;
9517 109 }
9518
9519 static bool did_init_def_items = false;
9520 56567 void init_def_items()
9521 {
9522
2/2
✓ Branch 0 taken 56534 times.
✓ Branch 1 taken 33 times.
56567 if(did_init_def_items) return;
9523 33 did_init_def_items = true;
9524 33 default_items[3].cost_counter[1] = crBOMBS;
9525 33 default_items[13].cost_counter[1] = crARROWS;
9526 33 default_items[14].cost_counter[1] = crARROWS;
9527 33 default_items[48].cost_counter[1] = crSBOMBS;
9528 33 default_items[57].cost_counter[1] = crARROWS;
9529 56567 }
9530 56567 void reset_itembuf(itemdata *item, int32_t id)
9531 {
9532 56567 init_def_items();
9533
2/2
✓ Branch 0 taken 24521 times.
✓ Branch 1 taken 32046 times.
56567 if(id<iLast)
9534 {
9535 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9536 32046 word tile = item->tile;
9537 32046 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9538 32046 int32_t ltm = item->ltm;
9539
9540 32046 memcpy(item,&default_items[id],sizeof(itemdata));
9541 32046 item->tile = tile;
9542 32046 item->misc_flags = miscs;
9543 32046 item->csets = cset;
9544 32046 item->frames = frames;
9545 32046 item->speed = speed;
9546 32046 item->delay = delay;
9547 32046 item->ltm = ltm;
9548 32046 }
9549 56567 }
9550
9551 10752 void reset_itemname(int32_t id)
9552 {
9553 10752 sprintf(item_string[id],"zz%03d",id);
9554
9555
2/2
✓ Branch 0 taken 4746 times.
✓ Branch 1 taken 6006 times.
10752 if(id < iLast)
9556 6006 strcpy(item_string[id],old_item_string[id]);
9557 10752 }
9558
9559 109 int32_t readweapons(PACKFILE *f, zquestheader *Header, bool keepdata)
9560 {
9561 109 word weapons_to_read=MAXWPNS;
9562 int32_t dummy;
9563 byte padding;
9564 wpndata tempweapon;
9565 109 word s_version=0, s_cversion=0;
9566
9567
9568
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if(Header->zelda_version < 0x186)
9569 {
9570 weapons_to_read=64;
9571 }
9572
9573
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if(Header->zelda_version < 0x185)
9574 {
9575 weapons_to_read=32;
9576 }
9577
9578
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 105 times.
109 if(Header->zelda_version > 0x192)
9579 {
9580 105 weapons_to_read=0;
9581
9582 //section version info
9583
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_version,f,true))
9584 {
9585 return qe_invalid;
9586 }
9587
9588 105 FFCore.quest_format[vWeaponSprites] = s_version;
9589
9590 //al_trace("Weapons version %d\n", s_version);
9591
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_cversion,f,true))
9592 {
9593 return qe_invalid;
9594 }
9595
9596 //section size
9597
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy,f,true))
9598 {
9599 return qe_invalid;
9600 }
9601
9602 //finally... section data
9603
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&weapons_to_read,f,true))
9604 {
9605 return qe_invalid;
9606 }
9607 105 }
9608
9609
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
109 if(s_version>2)
9610 {
9611
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 100 times.
25700 for(int32_t i=0; i<weapons_to_read; i++)
9612 {
9613 char tempname[64];
9614
9615
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(!pfread(tempname, 64, f, keepdata))
9616 {
9617 return qe_invalid;
9618 }
9619
9620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25600 times.
25600 if(keepdata)
9621 {
9622 25600 strcpy(weapon_string[i], tempname);
9623 25600 }
9624 25600 }
9625
9626
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(s_version<4)
9627 {
9628 if(keepdata)
9629 {
9630 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9631 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9632 }
9633 }
9634
9635
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(s_version<5)
9636 {
9637 if(keepdata)
9638 {
9639 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9640 }
9641 }
9642
9643 /*
9644 if (s_version<6)
9645 {
9646 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9647 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9648 }
9649 */
9650 100 }
9651 else
9652 {
9653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(keepdata)
9654
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<WPNCNT; i++)
9655 2313 reset_weaponname(i);
9656 }
9657
9658
2/2
✓ Branch 0 taken 26964 times.
✓ Branch 1 taken 109 times.
27073 for(int32_t i=0; i<weapons_to_read; i++)
9659 {
9660 26964 word oldtile = 0;
9661
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 21076 times.
26964 if (s_version < 8)
9662 {
9663
1/2
✓ Branch 0 taken 21076 times.
✗ Branch 1 not taken.
21076 if (!p_igetw(&oldtile, f, true))
9664 return qe_invalid;
9665 21076 }
9666
9667
1/2
✓ Branch 0 taken 26964 times.
✗ Branch 1 not taken.
26964 if(!p_getc(&tempweapon.misc,f,true))
9668 {
9669 return qe_invalid;
9670 }
9671
9672
1/2
✓ Branch 0 taken 26964 times.
✗ Branch 1 not taken.
26964 if(!p_getc(&tempweapon.csets,f,true))
9673 {
9674 return qe_invalid;
9675 }
9676
9677
1/2
✓ Branch 0 taken 26964 times.
✗ Branch 1 not taken.
26964 if(!p_getc(&tempweapon.frames,f,true))
9678 {
9679 return qe_invalid;
9680 }
9681
9682
1/2
✓ Branch 0 taken 26964 times.
✗ Branch 1 not taken.
26964 if(!p_getc(&tempweapon.speed,f,true))
9683 {
9684 return qe_invalid;
9685 }
9686
9687
1/2
✓ Branch 0 taken 26964 times.
✗ Branch 1 not taken.
26964 if(!p_getc(&tempweapon.type,f,true))
9688 {
9689 return qe_invalid;
9690 }
9691
9692
2/2
✓ Branch 0 taken 20564 times.
✓ Branch 1 taken 6400 times.
26964 if ( s_version >= 7 )
9693 {
9694
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetw(&tempweapon.script,f,true))
9695 {
9696 return qe_invalid;
9697 }
9698
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(!p_igetl(&tempweapon.tile,f,true))
9699 {
9700 return qe_invalid;
9701 }
9702 6400 }
9703
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 20564 times.
26964 if ( s_version < 7 )
9704 {
9705 20564 tempweapon.tile = oldtile;
9706 20564 }
9707
9708
2/2
✓ Branch 0 taken 25940 times.
✓ Branch 1 taken 1024 times.
26964 if(Header->zelda_version < 0x193)
9709 {
9710
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f,true))
9711 {
9712 return qe_invalid;
9713 }
9714 1024 }
9715
9716
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 1364 times.
26964 if(s_version < 6)
9717 {
9718
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1360 times.
1364 if(i==ewFIRETRAIL)
9719 {
9720 4 tempweapon.misc |= WF_BEHIND;
9721 4 }
9722 else
9723 1360 tempweapon.misc &= ~WF_BEHIND;
9724 1364 }
9725
9726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26964 times.
26964 if(keepdata==true)
9727 {
9728 26964 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9729 26964 }
9730 26964 }
9731
9732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(keepdata==true)
9733 {
9734
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
109 if(s_version<2)
9735 {
9736 9 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9737 9 }
9738
9739
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
109 if(s_version<5)
9740 {
9741 9 wpnsbuf[iwQuarterHearts].tile=1;
9742 9 wpnsbuf[iwQuarterHearts].csets=1;
9743 9 }
9744
9745
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if(Header->zelda_version < 0x176)
9746 {
9747 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9748 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9749 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9750 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9751 }
9752
9753
2/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
109 if((Header->zelda_version < 0x192)||
9754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9755 {
9756 4 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9757 4 }
9758
9759
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
109 if((Header->zelda_version < 0x210))
9760 {
9761 4 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9762 4 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9763 4 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9764 4 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9765 4 }
9766 109 }
9767
9768 109 return 0;
9769 109 }
9770
9771 109 void init_guys(int32_t guyversion)
9772 {
9773
2/2
✓ Branch 0 taken 55808 times.
✓ Branch 1 taken 109 times.
55917 for(int32_t i=0; i<MAXGUYS; i++)
9774 {
9775 55808 guysbuf[i] = default_guys[0];
9776 55808 }
9777
9778
2/2
✓ Branch 0 taken 19293 times.
✓ Branch 1 taken 109 times.
19402 for(int32_t i=0; i<OLDMAXGUYS; i++)
9779 {
9780 19293 guysbuf[i] = default_guys[i];
9781
2/2
✓ Branch 0 taken 19075 times.
✓ Branch 1 taken 218 times.
19293 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9782 19293 guysbuf[i].spr_death = iwDeath;
9783 19293 guysbuf[i].spr_spawn = iwSpawn;
9784 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9785
4/4
✓ Branch 0 taken 1593 times.
✓ Branch 1 taken 17700 times.
✓ Branch 2 taken 1584 times.
✓ Branch 3 taken 9 times.
19293 if(guyversion<=3 && i==ePATRABS)
9786 {
9787 9 guysbuf[i].bosspal=spDIG;
9788 9 guysbuf[i].cset=14;
9789 9 guysbuf[i].misc9=14;
9790 9 }
9791
9792
2/2
✓ Branch 0 taken 17700 times.
✓ Branch 1 taken 1593 times.
19293 if(guyversion<=3)
9793 {
9794 // Rope/Ghini Flash rules
9795
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 885 times.
1593 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9796 {
9797
2/2
✓ Branch 0 taken 880 times.
✓ Branch 1 taken 5 times.
885 if(i==eROPE2)
9798 {
9799 5 guysbuf[i].flags2 &= ~guy_flashing;
9800 5 }
9801 885 }
9802
9803
2/2
✓ Branch 0 taken 1062 times.
✓ Branch 1 taken 531 times.
1593 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9804 {
9805
12/12
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 525 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 522 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 519 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 516 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 513 times.
531 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9806 {
9807 18 guysbuf[i].flags2 &= ~guy_flashing;
9808 18 }
9809 531 }
9810
9811
2/2
✓ Branch 0 taken 1584 times.
✓ Branch 1 taken 9 times.
1593 if(i==eGHINI2)
9812 {
9813
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3 times.
9 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9814 {
9815 3 guysbuf[i].flags2 |= guy_blinking;
9816 3 }
9817
9818
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9819 {
9820 guysbuf[i].flags2 |= guy_transparent;
9821 }
9822 9 }
9823 1593 }
9824
9825 // Darknut fix
9826
10/10
✓ Branch 0 taken 19184 times.
✓ Branch 1 taken 109 times.
✓ Branch 2 taken 19075 times.
✓ Branch 3 taken 109 times.
✓ Branch 4 taken 18966 times.
✓ Branch 5 taken 109 times.
✓ Branch 6 taken 18857 times.
✓ Branch 7 taken 109 times.
✓ Branch 8 taken 109 times.
✓ Branch 9 taken 18748 times.
19293 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9827 {
9828
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 205 times.
545 if(get_bit(quest_rules,qr_NEWENEMYTILES))
9829 {
9830 340 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9831 340 guysbuf[i].s_width=guysbuf[i].e_width;
9832 340 guysbuf[i].s_height=guysbuf[i].e_height;
9833 340 }
9834 205 else guysbuf[i].s_tile=860;
9835
9836
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 35 times.
545 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9837 {
9838 35 guysbuf[i].flags |= guy_bkshield;
9839 35 }
9840 545 }
9841
9842
4/4
✓ Branch 0 taken 19184 times.
✓ Branch 1 taken 109 times.
✓ Branch 2 taken 19285 times.
✓ Branch 3 taken 8 times.
19293 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9843 {
9844 8 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9845 8 }
9846 19293 }
9847 109 }
9848
9849 2304 void reset_weaponname(int32_t i)
9850 {
9851
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 1512 times.
2304 if(i<wLast)
9852 {
9853 792 strcpy(weapon_string[i],old_weapon_string[i]);
9854 792 }
9855 else
9856 1512 sprintf(weapon_string[i],"zz%03d",i);
9857 2304 }
9858
9859 109 void init_item_drop_sets()
9860 {
9861
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9862 {
9863 // item_drop_sets[i] = default_item_drop_sets[0];
9864 27904 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9865 27904 }
9866
9867
2/2
✓ Branch 0 taken 1417 times.
✓ Branch 1 taken 109 times.
1526 for(int32_t i=0; i<isMAX; i++)
9868 {
9869 1417 item_drop_sets[i] = default_item_drop_sets[i];
9870
9871 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9872
2/2
✓ Branch 0 taken 14170 times.
✓ Branch 1 taken 1417 times.
15587 for(int32_t j=0; j<10; ++j)
9873 {
9874 14170 int32_t it = item_drop_sets[i].item[j];
9875
9876
3/4
✓ Branch 0 taken 9936 times.
✓ Branch 1 taken 4234 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 642 times.
14170 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9877
2/2
✓ Branch 0 taken 642 times.
✓ Branch 1 taken 9294 times.
9936 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9878 {
9879 642 item_drop_sets[i].chance[j+1]=0;
9880 642 }
9881
3/4
✓ Branch 0 taken 436 times.
✓ Branch 1 taken 13092 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 436 times.
13528 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9882 {
9883 item_drop_sets[i].chance[j+1]=0;
9884 }
9885
9886 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9887
2/2
✓ Branch 0 taken 14162 times.
✓ Branch 1 taken 8 times.
14170 if(itemsbuf[it].family == itype_misc)
9888 {
9889 // If a non-gameplay item was selected, then item drop was aborted.
9890 // Reflect this by increasing the 'Nothing' chance accordingly.
9891 8 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9892 8 item_drop_sets[i].chance[j+1]=0;
9893 8 }
9894 14170 }
9895 1417 }
9896 109 }
9897
9898 105 void init_favorites()
9899 {
9900
2/2
✓ Branch 0 taken 31500 times.
✓ Branch 1 taken 105 times.
31605 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9901 {
9902 31500 favorite_combos[i]=-1;
9903 31500 }
9904
9905
2/2
✓ Branch 0 taken 31500 times.
✓ Branch 1 taken 105 times.
31605 for(int32_t i=0; i<MAXFAVORITECOMBOALIASES; i++)
9906 {
9907 31500 favorite_comboaliases[i]=-1;
9908 31500 }
9909 105 }
9910
9911 const char *ctype_name[cMAX]=
9912 {
9913 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9914 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9915 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9916 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9917 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9918 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9919 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9920 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9921 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9922 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9923 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9924 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9925 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9926 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9927 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9928 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9929 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9930 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9931 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9932 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9933 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9934 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9935 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9936 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9937 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9938 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9939 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9940 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9941
9942 };
9943
9944 195 int32_t init_combo_classes()
9945 {
9946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 195 times.
195 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9947
2/2
✓ Branch 0 taken 35295 times.
✓ Branch 1 taken 195 times.
35490 for(int32_t i=0; i<cMAX; i++)
9948 {
9949 35295 combo_class_buf[i] = default_combo_classes[i];
9950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35295 times.
35295 if ( char const* nm = zi->getComboTypeName(i) )
9951 {
9952 35295 size_t len = strlen(nm);
9953
2/2
✓ Branch 0 taken 2258880 times.
✓ Branch 1 taken 35295 times.
2294175 for ( size_t q = 0; q < 64; q++ )
9954 {
9955
2/2
✓ Branch 0 taken 521625 times.
✓ Branch 1 taken 1737255 times.
2258880 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9956 2258880 }
9957 35295 }
9958 35295 }
9959
9960 195 return 0;
9961 }
9962
9963 88 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
9964 {
9965
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 assert(v_herosprites < 6);
9966 //these are here to bypass compiler warnings about unused arguments
9967 88 cv_herosprites=cv_herosprites;
9968
9969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(keepdata)
9970 {
9971 88 zinit.hero_swim_speed=67; //default
9972 88 setupherotiles(zinit.heroAnimationStyle);
9973 88 setupherodefenses();
9974 88 setupherooffsets();
9975 88 }
9976
9977
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 75 times.
88 if(v_herosprites>=0)
9978 {
9979 word tile, tile2;
9980 byte flip, extend, dummy_byte;
9981
9982
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 75 times.
375 for(int32_t i=0; i<4; i++)
9983 {
9984
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_igetw(&tile,f,keepdata))
9985 {
9986 return qe_invalid;
9987 }
9988
9989
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&flip,f,keepdata))
9990 {
9991 return qe_invalid;
9992 }
9993
9994
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&extend,f,keepdata))
9995 {
9996 return qe_invalid;
9997 }
9998
9999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300 times.
300 if(keepdata)
10000 {
10001 300 walkspr[i][spr_tile]=(int32_t)tile;
10002 300 walkspr[i][spr_flip]=(int32_t)flip;
10003 300 walkspr[i][spr_extend]=(int32_t)extend;
10004 300 }
10005 300 }
10006
10007
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 75 times.
375 for(int32_t i=0; i<4; i++)
10008 {
10009
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_igetw(&tile,f,keepdata))
10010 {
10011 return qe_invalid;
10012 }
10013
10014
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&flip,f,keepdata))
10015 {
10016 return qe_invalid;
10017 }
10018
10019
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&extend,f,keepdata))
10020 {
10021 return qe_invalid;
10022 }
10023
10024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300 times.
300 if(keepdata)
10025 {
10026 300 stabspr[i][spr_tile]=(int32_t)tile;
10027 300 stabspr[i][spr_flip]=(int32_t)flip;
10028 300 stabspr[i][spr_extend]=(int32_t)extend;
10029 300 }
10030 300 }
10031
10032
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 75 times.
375 for(int32_t i=0; i<4; i++)
10033 {
10034
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_igetw(&tile,f,keepdata))
10035 {
10036 return qe_invalid;
10037 }
10038
10039
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&flip,f,keepdata))
10040 {
10041 return qe_invalid;
10042 }
10043
10044
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&extend,f,keepdata))
10045 {
10046 return qe_invalid;
10047 }
10048
10049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300 times.
300 if(keepdata)
10050 {
10051 300 slashspr[i][spr_tile]=(int32_t)tile;
10052 300 slashspr[i][spr_flip]=(int32_t)flip;
10053 300 slashspr[i][spr_extend]=(int32_t)extend;
10054 300 }
10055 300 }
10056
10057
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 75 times.
375 for(int32_t i=0; i<4; i++)
10058 {
10059
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_igetw(&tile,f,keepdata))
10060 {
10061 return qe_invalid;
10062 }
10063
10064
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&flip,f,keepdata))
10065 {
10066 return qe_invalid;
10067 }
10068
10069
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&extend,f,keepdata))
10070 {
10071 return qe_invalid;
10072 }
10073
10074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300 times.
300 if(keepdata)
10075 {
10076 300 floatspr[i][spr_tile]=(int32_t)tile;
10077 300 floatspr[i][spr_flip]=(int32_t)flip;
10078 300 floatspr[i][spr_extend]=(int32_t)extend;
10079 300 }
10080 300 }
10081
10082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(v_herosprites>1)
10083 {
10084
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 75 times.
375 for(int32_t i=0; i<4; i++)
10085 {
10086
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_igetw(&tile,f,keepdata))
10087 {
10088 return qe_invalid;
10089 }
10090
10091
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&flip,f,keepdata))
10092 {
10093 return qe_invalid;
10094 }
10095
10096
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&extend,f,keepdata))
10097 {
10098 return qe_invalid;
10099 }
10100
10101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300 times.
300 if(keepdata)
10102 {
10103 300 swimspr[i][spr_tile]=(int32_t)tile;
10104 300 swimspr[i][spr_flip]=(int32_t)flip;
10105 300 swimspr[i][spr_extend]=(int32_t)extend;
10106 300 }
10107 300 }
10108 75 }
10109
10110
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 75 times.
375 for(int32_t i=0; i<4; i++)
10111 {
10112
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_igetw(&tile,f,keepdata))
10113 {
10114 return qe_invalid;
10115 }
10116
10117
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&flip,f,keepdata))
10118 {
10119 return qe_invalid;
10120 }
10121
10122
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&extend,f,keepdata))
10123 {
10124 return qe_invalid;
10125 }
10126
10127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300 times.
300 if(keepdata)
10128 {
10129 300 divespr[i][spr_tile]=(int32_t)tile;
10130 300 divespr[i][spr_flip]=(int32_t)flip;
10131 300 divespr[i][spr_extend]=(int32_t)extend;
10132 300 }
10133 300 }
10134
10135
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 75 times.
375 for(int32_t i=0; i<4; i++)
10136 {
10137
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_igetw(&tile,f,keepdata))
10138 {
10139 return qe_invalid;
10140 }
10141
10142
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&flip,f,keepdata))
10143 {
10144 return qe_invalid;
10145 }
10146
10147
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&extend,f,keepdata))
10148 {
10149 return qe_invalid;
10150 }
10151
10152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300 times.
300 if(keepdata)
10153 {
10154 300 poundspr[i][spr_tile]=(int32_t)tile;
10155 300 poundspr[i][spr_flip]=(int32_t)flip;
10156 300 poundspr[i][spr_extend]=(int32_t)extend;
10157 300 }
10158 300 }
10159
10160
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetw(&tile,f,keepdata))
10161 {
10162 return qe_invalid;
10163 }
10164
10165 75 flip=0;
10166
10167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(v_herosprites>0)
10168 {
10169
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&flip,f,keepdata))
10170 {
10171 return qe_invalid;
10172 }
10173 75 }
10174
10175
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&extend,f,keepdata))
10176 {
10177 return qe_invalid;
10178 }
10179
10180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(keepdata)
10181 {
10182 75 castingspr[spr_tile]=(int32_t)tile;
10183 75 castingspr[spr_flip]=(int32_t)flip;
10184 75 castingspr[spr_extend]=(int32_t)extend;
10185 75 }
10186
10187
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(v_herosprites>0)
10188 {
10189 75 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10190
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 75 times.
225 for(int32_t i=0; i<2; i++)
10191 {
10192
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 150 times.
450 for(int32_t j=0; j<num_holdsprs; j++)
10193 {
10194
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_igetw(&tile,f,keepdata))
10195 {
10196 return qe_invalid;
10197 }
10198
10199
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&flip,f,keepdata))
10200 {
10201 return qe_invalid;
10202 }
10203
10204
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&extend,f,keepdata))
10205 {
10206 return qe_invalid;
10207 }
10208
10209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300 times.
300 if(keepdata)
10210 {
10211 300 holdspr[i][j][spr_tile]=(int32_t)tile;
10212 300 holdspr[i][j][spr_flip]=(int32_t)flip;
10213 300 holdspr[i][j][spr_extend]=(int32_t)extend;
10214 300 }
10215 300 }
10216 150 }
10217 75 }
10218 else
10219 {
10220 for(int32_t i=0; i<2; i++)
10221 {
10222 if(!p_igetw(&tile,f,keepdata))
10223 {
10224 return qe_invalid;
10225 }
10226
10227 if(!p_igetw(&tile2,f,keepdata))
10228 {
10229 return qe_invalid;
10230 }
10231
10232 if(!p_getc(&extend,f,keepdata))
10233 {
10234 return qe_invalid;
10235 }
10236
10237 if(keepdata)
10238 {
10239 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10240 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10241 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10242 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10243 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10244 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10245 }
10246 }
10247 }
10248
10249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(v_herosprites>2)
10250 {
10251
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 75 times.
375 for(int32_t i=0; i<4; i++)
10252 {
10253
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_igetw(&tile,f,keepdata))
10254 {
10255 return qe_invalid;
10256 }
10257
10258
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&flip,f,keepdata))
10259 {
10260 return qe_invalid;
10261 }
10262
10263
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&extend,f,keepdata))
10264 {
10265 return qe_invalid;
10266 }
10267
10268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300 times.
300 if(keepdata)
10269 {
10270 300 jumpspr[i][spr_tile]=(int32_t)tile;
10271 300 jumpspr[i][spr_flip]=(int32_t)flip;
10272 300 jumpspr[i][spr_extend]=(int32_t)extend;
10273 300 }
10274 300 }
10275 75 }
10276
10277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(v_herosprites>3)
10278 {
10279
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 75 times.
375 for(int32_t i=0; i<4; i++)
10280 {
10281
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_igetw(&tile,f,keepdata))
10282 {
10283 return qe_invalid;
10284 }
10285
10286
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&flip,f,keepdata))
10287 {
10288 return qe_invalid;
10289 }
10290
10291
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(!p_getc(&extend,f,keepdata))
10292 {
10293 return qe_invalid;
10294 }
10295
10296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300 times.
300 if(keepdata)
10297 {
10298 300 chargespr[i][spr_tile]=(int32_t)tile;
10299 300 chargespr[i][spr_flip]=(int32_t)flip;
10300 300 chargespr[i][spr_extend]=(int32_t)extend;
10301 300 }
10302 300 }
10303 75 }
10304
10305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(v_herosprites>4)
10306 {
10307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(!p_getc(&dummy_byte,f,keepdata))
10308 {
10309 return qe_invalid;
10310 }
10311
10312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(keepdata)
10313 {
10314 75 zinit.hero_swim_speed=(byte)dummy_byte;
10315 75 }
10316 75 }
10317
10318
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(keepdata)
10319 {
10320 75 memset(frozenspr, 0, sizeof(frozenspr));
10321 75 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10322 75 memset(onfirespr, 0, sizeof(onfirespr));
10323 75 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10324 75 memset(diggingspr, 0, sizeof(diggingspr));
10325 75 memset(usingrodspr, 0, sizeof(usingrodspr));
10326 75 memset(usingcanespr, 0, sizeof(usingcanespr));
10327 75 memset(pushingspr, 0, sizeof(pushingspr));
10328 75 memset(liftingspr, 0, sizeof(liftingspr));
10329 75 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10330 75 memset(stunnedspr, 0, sizeof(stunnedspr));
10331 75 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10332 75 memset(fallingspr, 0, sizeof(fallingspr));
10333 75 memset(shockedspr, 0, sizeof(shockedspr));
10334 75 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10335 75 memset(pullswordspr, 0, sizeof(pullswordspr));
10336 75 memset(readingspr, 0, sizeof(readingspr));
10337 75 memset(slash180spr, 0, sizeof(slash180spr));
10338 75 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10339 75 memset(dashspr, 0, sizeof(dashspr));
10340 75 memset(bonkspr, 0, sizeof(bonkspr));
10341 75 memset(medallionsprs, 0, sizeof(medallionsprs));
10342 75 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10343 75 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10344
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 75 times.
375 for(int32_t q = 0; q < 4; ++q)
10345 {
10346
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 300 times.
1200 for(int32_t p = 0; p < 3; ++p)
10347 {
10348 900 drowningspr[q][p] = divespr[q][p];
10349 900 drowning_lavaspr[q][p] = divespr[q][p];
10350 900 }
10351 300 }
10352 75 memset(sideswimspr, 0, sizeof(sideswimspr));
10353 75 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10354 75 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10355 75 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10356 75 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10357 75 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10358 75 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10359 75 }
10360 75 }
10361
10362
2/4
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 88 times.
88 if(keepdata && FFCore.quest_format[vInitData] < 34)
10363 {
10364 88 bool fastswim = zinit.hero_swim_speed > 60;
10365 // '2/3' or '1/2'
10366 88 zinit.hero_swim_mult = fastswim ? 2 : 1;
10367 88 zinit.hero_swim_div = fastswim ? 3 : 2;
10368 88 }
10369 88 return 0;
10370 88 }
10371
10372 4250 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10373 {
10374 4250 arr[spr_tile] = tile;
10375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4250 times.
4250 arr[spr_flip] = (flip > 3 ? 0 : flip);
10376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4250 times.
4250 arr[spr_extend] = (ext > 2 ? 0 : ext);
10377 4250 }
10378 //Used to read the player sprites as int32_t, not word.
10379 25 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
10380 {
10381 //these are here to bypass compiler warnings about unused arguments
10382 25 cv_herosprites=cv_herosprites;
10383
10384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata)
10385 {
10386 25 zinit.hero_swim_speed=67; //default
10387 25 setupherotiles(zinit.heroAnimationStyle);
10388 25 setupherodefenses();
10389 25 setupherooffsets();
10390 25 }
10391
10392 int32_t tile, tile2;
10393 byte flip, extend, dummy_byte;
10394
10395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(v_herosprites>=0)
10396 {
10397
10398
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t i=0; i<4; i++)
10399 {
10400
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10401 {
10402 return qe_invalid;
10403 }
10404
10405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&flip,f,keepdata))
10406 {
10407 return qe_invalid;
10408 }
10409
10410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
10411 {
10412 return qe_invalid;
10413 }
10414
10415 100 if(keepdata)
10416 {
10417 100 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10418 100 }
10419 100 }
10420
10421
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t i=0; i<4; i++)
10422 {
10423
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10424 {
10425 return qe_invalid;
10426 }
10427
10428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&flip,f,keepdata))
10429 {
10430 return qe_invalid;
10431 }
10432
10433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
10434 {
10435 return qe_invalid;
10436 }
10437
10438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10439 {
10440 100 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10441 100 }
10442 100 }
10443
10444
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t i=0; i<4; i++)
10445 {
10446
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10447 {
10448 return qe_invalid;
10449 }
10450
10451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&flip,f,keepdata))
10452 {
10453 return qe_invalid;
10454 }
10455
10456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
10457 {
10458 return qe_invalid;
10459 }
10460
10461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10462 {
10463 100 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10464 100 }
10465 100 }
10466
10467
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t i=0; i<4; i++)
10468 {
10469
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10470 {
10471 return qe_invalid;
10472 }
10473
10474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&flip,f,keepdata))
10475 {
10476 return qe_invalid;
10477 }
10478
10479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
10480 {
10481 return qe_invalid;
10482 }
10483
10484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10485 {
10486 100 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10487 100 }
10488 100 }
10489
10490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(v_herosprites>1)
10491 {
10492
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t i=0; i<4; i++)
10493 {
10494
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10495 {
10496 return qe_invalid;
10497 }
10498
10499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&flip,f,keepdata))
10500 {
10501 return qe_invalid;
10502 }
10503
10504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
10505 {
10506 return qe_invalid;
10507 }
10508
10509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10510 {
10511 100 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10512 100 }
10513 100 }
10514 25 }
10515
10516
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t i=0; i<4; i++)
10517 {
10518
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10519 {
10520 return qe_invalid;
10521 }
10522
10523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&flip,f,keepdata))
10524 {
10525 return qe_invalid;
10526 }
10527
10528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
10529 {
10530 return qe_invalid;
10531 }
10532
10533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10534 {
10535 100 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10536 100 }
10537 100 }
10538
10539
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t i=0; i<4; i++)
10540 {
10541
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10542 {
10543 return qe_invalid;
10544 }
10545
10546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&flip,f,keepdata))
10547 {
10548 return qe_invalid;
10549 }
10550
10551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
10552 {
10553 return qe_invalid;
10554 }
10555
10556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10557 {
10558 100 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10559 100 }
10560 100 }
10561
10562
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&tile,f,keepdata))
10563 {
10564 return qe_invalid;
10565 }
10566
10567 25 flip=0;
10568
10569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(v_herosprites>0)
10570 {
10571
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&flip,f,keepdata))
10572 {
10573 return qe_invalid;
10574 }
10575 25 }
10576
10577
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&extend,f,keepdata))
10578 {
10579 return qe_invalid;
10580 }
10581
10582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata)
10583 {
10584 25 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10585 25 }
10586
10587
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(v_herosprites>0)
10588 {
10589 25 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10590
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 25 times.
75 for(int32_t i=0; i<2; i++)
10591 {
10592
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 50 times.
200 for(int32_t j=0; j<num_holdsprs; j++)
10593 {
10594
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 if(!p_igetl(&tile,f,keepdata))
10595 {
10596 return qe_invalid;
10597 }
10598
10599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
150 if(!p_getc(&flip,f,keepdata))
10600 {
10601 return qe_invalid;
10602 }
10603
10604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
150 if(!p_getc(&extend,f,keepdata))
10605 {
10606 return qe_invalid;
10607 }
10608
10609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
150 if(keepdata)
10610 {
10611 150 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10612 150 }
10613 150 }
10614 50 }
10615 25 }
10616 else
10617 {
10618 for(int32_t i=0; i<2; i++)
10619 {
10620 if(!p_igetl(&tile,f,keepdata))
10621 {
10622 return qe_invalid;
10623 }
10624
10625 if(!p_igetl(&tile2,f,keepdata))
10626 {
10627 return qe_invalid;
10628 }
10629
10630 if(!p_getc(&extend,f,keepdata))
10631 {
10632 return qe_invalid;
10633 }
10634
10635 if(keepdata)
10636 {
10637 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10638 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10639 }
10640 }
10641 }
10642
10643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(v_herosprites>2)
10644 {
10645
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t i=0; i<4; i++)
10646 {
10647
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10648 {
10649 return qe_invalid;
10650 }
10651
10652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&flip,f,keepdata))
10653 {
10654 return qe_invalid;
10655 }
10656
10657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
10658 {
10659 return qe_invalid;
10660 }
10661
10662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10663 {
10664 100 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10665 100 }
10666 100 }
10667 25 }
10668
10669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(v_herosprites>3)
10670 {
10671
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t i=0; i<4; i++)
10672 {
10673
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10674 {
10675 return qe_invalid;
10676 }
10677
10678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&flip,f,keepdata))
10679 {
10680 return qe_invalid;
10681 }
10682
10683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
10684 {
10685 return qe_invalid;
10686 }
10687
10688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10689 {
10690 100 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10691 100 }
10692 100 }
10693 25 }
10694
10695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(v_herosprites>4)
10696 {
10697
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&dummy_byte,f,keepdata))
10698 {
10699 return qe_invalid;
10700 }
10701
10702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(keepdata)
10703 {
10704 25 zinit.hero_swim_speed=(byte)dummy_byte;
10705 25 }
10706 25 }
10707
10708
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(v_herosprites>6)
10709 {
10710
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
10711 {
10712
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10713 return qe_invalid;
10714
10715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&flip,f,keepdata))
10716 return qe_invalid;
10717
10718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
10719 return qe_invalid;
10720
10721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10722 {
10723 100 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10724 100 }
10725 100 }
10726
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
10727 {
10728
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10729 return qe_invalid;
10730
10731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&flip,f,keepdata))
10732 return qe_invalid;
10733
10734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
10735 return qe_invalid;
10736
10737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10738 {
10739 100 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10740 100 }
10741 100 }
10742
10743
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
10744 {
10745
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10746 return qe_invalid;
10747
10748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&flip,f,keepdata))
10749 return qe_invalid;
10750
10751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
10752 return qe_invalid;
10753
10754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10755 {
10756 100 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10757 100 }
10758 100 }
10759
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
10760 {
10761
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10762 return qe_invalid;
10763
10764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&flip,f,keepdata))
10765 return qe_invalid;
10766
10767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
10768 return qe_invalid;
10769
10770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10771 {
10772 100 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10773 100 }
10774 100 }
10775
10776
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
10777 {
10778
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10779 return qe_invalid;
10780
10781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&flip,f,keepdata))
10782 return qe_invalid;
10783
10784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
10785 return qe_invalid;
10786
10787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10788 {
10789 100 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10790 100 }
10791 100 }
10792
10793
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
10794 {
10795
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10796 return qe_invalid;
10797
10798
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&flip,f,keepdata))
10799 return qe_invalid;
10800
10801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
10802 return qe_invalid;
10803
10804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10805 {
10806 100 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10807 100 }
10808 100 }
10809
10810
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
10811 {
10812
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10813 return qe_invalid;
10814
10815
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&flip,f,keepdata))
10816 return qe_invalid;
10817
10818
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&extend,f,keepdata))
10819 return qe_invalid;
10820
10821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10822 {
10823 100 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10824 100 }
10825 100 }
10826
10827
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
10828 {
10829
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10830 return qe_invalid;
10831
10832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&flip,f,keepdata))
10833 return qe_invalid;
10834
10835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
10836 return qe_invalid;
10837
10838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10839 {
10840 100 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10841 100 }
10842 100 }
10843
10844
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
10845 {
10846
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10847 return qe_invalid;
10848
10849
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&flip,f,keepdata))
10850 return qe_invalid;
10851
10852
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&extend,f,keepdata))
10853 return qe_invalid;
10854
10855 100 byte frames = 0;
10856
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 92 times.
100 if(v_herosprites > 15)
10857 {
10858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&frames,f,keepdata))
10859 return qe_invalid;
10860 92 }
10861
10862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10863 {
10864 100 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10865 100 liftingspr[q][spr_frames] = frames;
10866 100 }
10867 100 }
10868
10869
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
10870 {
10871
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10872 return qe_invalid;
10873
10874
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&flip,f,keepdata))
10875 return qe_invalid;
10876
10877
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&extend,f,keepdata))
10878 return qe_invalid;
10879
10880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10881 {
10882 100 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10883 100 }
10884 100 }
10885
10886
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
10887 {
10888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_igetl(&tile,f,keepdata))
10889 return qe_invalid;
10890
10891
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&flip,f,keepdata))
10892 return qe_invalid;
10893
10894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
10895 return qe_invalid;
10896
10897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10898 {
10899 100 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10900 100 }
10901 100 }
10902
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
10903 {
10904
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10905 return qe_invalid;
10906
10907
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&flip,f,keepdata))
10908 return qe_invalid;
10909
10910
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&extend,f,keepdata))
10911 return qe_invalid;
10912
10913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10914 {
10915 100 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10916 100 }
10917 100 }
10918
10919
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
10920 {
10921
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10922 return qe_invalid;
10923
10924
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&flip,f,keepdata))
10925 return qe_invalid;
10926
10927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
10928 return qe_invalid;
10929
10930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10931 {
10932 100 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10933 100 }
10934 100 }
10935
10936
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
10937 {
10938
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10939 return qe_invalid;
10940
10941
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&flip,f,keepdata))
10942 return qe_invalid;
10943
10944
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&extend,f,keepdata))
10945 return qe_invalid;
10946
10947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10948 {
10949 100 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10950 100 }
10951 100 }
10952
10953
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
10954 {
10955
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10956 return qe_invalid;
10957
10958
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&flip,f,keepdata))
10959 return qe_invalid;
10960
10961
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&extend,f,keepdata))
10962 return qe_invalid;
10963
10964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10965 {
10966 100 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10967 100 }
10968 100 }
10969
10970
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
10971 {
10972
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10973 return qe_invalid;
10974
10975
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&flip,f,keepdata))
10976 return qe_invalid;
10977
10978
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&extend,f,keepdata))
10979 return qe_invalid;
10980
10981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10982 {
10983 100 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10984 100 }
10985 100 }
10986
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
10987 {
10988
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
10989 return qe_invalid;
10990
10991
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&flip,f,keepdata))
10992 return qe_invalid;
10993
10994
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&extend,f,keepdata))
10995 return qe_invalid;
10996
10997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
10998 {
10999 100 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11000 100 }
11001 100 }
11002
11003
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
11004 {
11005
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
11006 return qe_invalid;
11007
11008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&flip,f,keepdata))
11009 return qe_invalid;
11010
11011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
11012 return qe_invalid;
11013
11014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
11015 {
11016 100 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11017 100 }
11018 100 }
11019
11020
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
11021 {
11022
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
11023 return qe_invalid;
11024
11025
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&flip,f,keepdata))
11026 return qe_invalid;
11027
11028
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&extend,f,keepdata))
11029 return qe_invalid;
11030
11031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
11032 {
11033 100 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11034 100 }
11035 100 }
11036
11037
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
11038 {
11039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_igetl(&tile,f,keepdata))
11040 return qe_invalid;
11041
11042
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&flip,f,keepdata))
11043 return qe_invalid;
11044
11045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
11046 return qe_invalid;
11047
11048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
11049 {
11050 100 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11051 100 }
11052 100 }
11053
11054
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
11055 {
11056
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
11057 return qe_invalid;
11058
11059
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&flip,f,keepdata))
11060 return qe_invalid;
11061
11062
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&extend,f,keepdata))
11063 return qe_invalid;
11064
11065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
11066 {
11067 100 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11068 100 }
11069 100 }
11070
11071
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
11072 {
11073
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
11074 return qe_invalid;
11075
11076
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&flip,f,keepdata))
11077 return qe_invalid;
11078
11079
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&extend,f,keepdata))
11080 return qe_invalid;
11081
11082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
11083 {
11084 100 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11085 100 }
11086 100 }
11087
11088
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
11089 {
11090
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
11091 return qe_invalid;
11092
11093
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&flip,f,keepdata))
11094 return qe_invalid;
11095
11096
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&extend,f,keepdata))
11097 return qe_invalid;
11098
11099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
11100 {
11101 100 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11102 100 }
11103 100 }
11104
11105
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 25 times.
100 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
11106 {
11107
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetl(&tile,f,keepdata))
11108 return qe_invalid;
11109
11110
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&flip,f,keepdata))
11111 return qe_invalid;
11112
11113
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_getc(&extend,f,keepdata))
11114 return qe_invalid;
11115
11116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(keepdata)
11117 {
11118 75 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
11119 75 }
11120 75 }
11121 25 }
11122 else if(keepdata)
11123 {
11124 memset(frozenspr, 0, sizeof(frozenspr));
11125 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
11126 memset(onfirespr, 0, sizeof(onfirespr));
11127 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
11128 memset(diggingspr, 0, sizeof(diggingspr));
11129 memset(usingrodspr, 0, sizeof(usingrodspr));
11130 memset(usingcanespr, 0, sizeof(usingcanespr));
11131 memset(pushingspr, 0, sizeof(pushingspr));
11132 memset(liftingspr, 0, sizeof(liftingspr));
11133 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
11134 memset(stunnedspr, 0, sizeof(stunnedspr));
11135 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
11136 memset(fallingspr, 0, sizeof(fallingspr));
11137 memset(shockedspr, 0, sizeof(shockedspr));
11138 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
11139 memset(pullswordspr, 0, sizeof(pullswordspr));
11140 memset(readingspr, 0, sizeof(readingspr));
11141 memset(slash180spr, 0, sizeof(slash180spr));
11142 memset(slashZ4spr, 0, sizeof(slashZ4spr));
11143 memset(dashspr, 0, sizeof(dashspr));
11144 memset(bonkspr, 0, sizeof(bonkspr));
11145 memset(medallionsprs, 0, sizeof(medallionsprs));
11146 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
11147 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
11148 for(int32_t q = 0; q < 4; ++q)
11149 {
11150 for(int32_t p = 0; p < 3; ++p)
11151 {
11152 drowningspr[q][p] = divespr[q][p];
11153 drowning_lavaspr[q][p] = divespr[q][p];
11154 }
11155 }
11156 }
11157
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if (v_herosprites > 8)
11158 {
11159
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
11160 {
11161
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
11162 return qe_invalid;
11163
11164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&flip,f,keepdata))
11165 return qe_invalid;
11166
11167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
11168 return qe_invalid;
11169
11170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
11171 {
11172 100 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11173 100 }
11174 100 }
11175 25 }
11176 else if (keepdata)
11177 {
11178 memset(sideswimspr, 0, sizeof(sideswimspr));
11179 }
11180
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if (v_herosprites > 9)
11181 {
11182
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
11183 {
11184
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
11185 return qe_invalid;
11186
11187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&flip,f,keepdata))
11188 return qe_invalid;
11189
11190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
11191 return qe_invalid;
11192
11193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
11194 {
11195 100 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11196 100 }
11197 100 }
11198
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
11199 {
11200
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
11201 return qe_invalid;
11202
11203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&flip,f,keepdata))
11204 return qe_invalid;
11205
11206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
11207 return qe_invalid;
11208
11209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
11210 {
11211 100 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11212 100 }
11213 100 }
11214
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
11215 {
11216
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
11217 return qe_invalid;
11218
11219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&flip,f,keepdata))
11220 return qe_invalid;
11221
11222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
11223 return qe_invalid;
11224
11225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
11226 {
11227 100 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11228 100 }
11229 100 }
11230
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
11231 {
11232
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
11233 return qe_invalid;
11234
11235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&flip,f,keepdata))
11236 return qe_invalid;
11237
11238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
11239 return qe_invalid;
11240
11241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
11242 {
11243 100 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11244 100 }
11245 100 }
11246 25 }
11247 else if (keepdata)
11248 {
11249 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11250 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11251 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11252 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11253 }
11254
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if (v_herosprites > 10)
11255 {
11256
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
11257 {
11258 int32_t hmr;
11259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_igetl(&hmr,f,keepdata))
11260 return qe_invalid;
11261
11262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
11263 {
11264 100 hammeroffsets[q] = hmr;
11265 100 }
11266 100 }
11267 25 }
11268 else if (keepdata)
11269 {
11270 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11271 }
11272
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if (v_herosprites > 11)
11273 {
11274
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 25 times.
100 for(int32_t q = 0; q < 3; ++q)
11275 {
11276
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(!p_igetl(&tile,f,keepdata))
11277 return qe_invalid;
11278
11279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(!p_getc(&flip,f,keepdata))
11280 return qe_invalid;
11281
11282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(!p_getc(&extend,f,keepdata))
11283 return qe_invalid;
11284
11285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(keepdata)
11286 {
11287 75 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11288 75 }
11289 75 }
11290 25 }
11291 else if (keepdata)
11292 {
11293 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11294 }
11295
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if (v_herosprites > 12)
11296 {
11297
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&tile,f,keepdata))
11298 return qe_invalid;
11299
11300
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&flip,f,keepdata))
11301 return qe_invalid;
11302
11303
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_getc(&extend,f,keepdata))
11304 return qe_invalid;
11305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if (keepdata)
11306 {
11307 25 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11308 25 }
11309
11310 25 }
11311 else if (keepdata)
11312 {
11313 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11314 }
11315
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if (v_herosprites > 13)
11316 {
11317
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
11318 {
11319
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
11320 return qe_invalid;
11321
11322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&flip,f,keepdata))
11323 return qe_invalid;
11324
11325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
11326 return qe_invalid;
11327
11328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
11329 {
11330 100 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11331 100 }
11332 100 }
11333 25 }
11334 else if (keepdata)
11335 {
11336 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11337 }
11338
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if (v_herosprites > 14)
11339 {
11340
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 25 times.
125 for(int32_t q = 0; q < 4; ++q)
11341 {
11342
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&tile,f,keepdata))
11343 return qe_invalid;
11344
11345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&flip,f,keepdata))
11346 return qe_invalid;
11347
11348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_getc(&extend,f,keepdata))
11349 return qe_invalid;
11350
11351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
11352 {
11353 100 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11354 100 }
11355 100 }
11356 25 }
11357 else if (keepdata)
11358 {
11359 memset(revslashspr, 0, sizeof(revslashspr));
11360 }
11361
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if (v_herosprites > 7)
11362 {
11363 25 int32_t num_defense = wMax;
11364 25 byte def = 0;
11365
11366 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11367 /*if(v_herosprites > [x])
11368 * {
11369 * num_defense = 146 //value of wMax on version 8
11370 * }
11371 */
11372
11373
2/2
✓ Branch 0 taken 3650 times.
✓ Branch 1 taken 25 times.
3675 for (int32_t q = 0; q < num_defense; q++)
11374 {
11375
1/2
✓ Branch 0 taken 3650 times.
✗ Branch 1 not taken.
3650 if (!p_getc(&def, f, keepdata))
11376 return qe_invalid;
11377
11378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3650 times.
3650 if (keepdata)
11379 {
11380 3650 hero_defence[q] = def;
11381 3650 }
11382 3650 }
11383 25 }
11384 else if (keepdata)
11385 {
11386 int32_t num_defense = wMax;
11387 for (int32_t q = 0; q < num_defense; q++)
11388 {
11389 hero_defence[q] = 0;
11390 }
11391 }
11392 25 }
11393
11394
3/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 15 times.
25 if(keepdata && FFCore.quest_format[vInitData] < 34)
11395 {
11396 15 bool fastswim = zinit.hero_swim_speed > 60;
11397 // '2/3' or '1/2'
11398 15 zinit.hero_swim_mult = fastswim ? 2 : 1;
11399 15 zinit.hero_swim_div = fastswim ? 3 : 2;
11400 15 }
11401 25 return 0;
11402 25 }
11403
11404
11405 100 int32_t readherosprites(PACKFILE *f, zquestheader *Header, bool keepdata)
11406 {
11407 //these are here to bypass compiler warnings about unused arguments
11408 100 Header=Header;
11409
11410 dword dummy;
11411 100 word s_version=0, s_cversion=0;
11412
11413 //section version info
11414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_igetw(&s_version,f,true))
11415 {
11416 return qe_invalid;
11417 }
11418
11419 100 FFCore.quest_format[vHeroSprites] = s_version;
11420
11421 //al_trace("Player sprites version %d\n", s_version);
11422
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetw(&s_cversion,f,true))
11423 {
11424 return qe_invalid;
11425 }
11426
11427 //section size
11428
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&dummy,f,true))
11429 {
11430 return qe_invalid;
11431 }
11432
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 75 times.
100 if ( s_version >= 6 )
11433 {
11434 //al_trace("Reading Player Sprites v6\n");
11435 25 return readherosprites3(f, s_version, dummy, keepdata);
11436 }
11437 75 else return readherosprites2(f, s_version, dummy, keepdata);
11438 100 }
11439
11440 100 int32_t readsubscreens(PACKFILE *f, zquestheader *Header, bool keepdata)
11441 {
11442 int32_t dummy;
11443 100 word s_version=0, s_cversion=0;
11444
11445 //section version info
11446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_igetw(&s_version,f,true))
11447 {
11448 return qe_invalid;
11449 }
11450
11451 100 FFCore.quest_format[vSubscreen] = s_version;
11452
11453 //al_trace("Subscreens version %d\n", s_version);
11454
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetw(&s_cversion,f,true))
11455 {
11456 return qe_invalid;
11457 }
11458
11459 //section size
11460
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&dummy,f,true))
11461 {
11462 return qe_invalid;
11463 }
11464
11465 //finally... section data
11466
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 100 times.
12900 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11467 {
11468 12800 int32_t ret = read_one_subscreen(f, Header, keepdata, i, s_version, s_cversion);
11469
11470
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(ret!=0) return ret;
11471 12800 }
11472
11473 100 return 0;
11474 100 }
11475
11476 12800 int32_t read_one_subscreen(PACKFILE *f, zquestheader *, bool keepdata, int32_t i, word s_version, word)
11477 {
11478 12800 int32_t numsub=0;
11479 12800 byte temp_ss=0;
11480 subscreen_object temp_sub_stack;
11481 12800 subscreen_object *temp_sub = &temp_sub_stack;
11482
11483 char tempname[64];
11484
11485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12800 times.
12800 if(!pfread(tempname,64,f,true))
11486 {
11487 return qe_invalid;
11488 }
11489
11490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12800 times.
12800 if(s_version > 1)
11491 {
11492
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&temp_ss,f,keepdata))
11493 {
11494 return qe_invalid;
11495 }
11496 12800 }
11497
11498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12800 times.
12800 if(s_version < 4)
11499 {
11500 uint8_t tmp=0;
11501
11502 if(!p_getc(&tmp,f,true))
11503 {
11504 return qe_invalid;
11505 }
11506
11507 numsub = (int32_t)tmp;
11508 }
11509 else
11510 {
11511 word tmp;
11512
11513
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&tmp, f, true))
11514 {
11515 return qe_invalid;
11516 }
11517
11518 12800 numsub = (int32_t)tmp;
11519 }
11520
11521 int32_t j;
11522
11523
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34281 times.
✓ Branch 2 taken 21481 times.
✓ Branch 3 taken 12800 times.
34281 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11524 {
11525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21481 times.
21481 if(keepdata)
11526 {
11527 21481 memset(temp_sub,0,sizeof(subscreen_object));
11528
11529
2/2
✓ Branch 0 taken 1199 times.
✓ Branch 1 taken 20282 times.
21481 switch(custom_subscreen[i].objects[j].type)
11530 {
11531 case ssoTEXT:
11532 case ssoTEXTBOX:
11533 case ssoCURRENTITEMTEXT:
11534 case ssoCURRENTITEMCLASSTEXT:
11535
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1199 times.
✓ Branch 2 taken 1199 times.
✗ Branch 3 not taken.
1199 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11536
11537 //fall through
11538 default:
11539 21481 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11540 21481 break;
11541 }
11542 21481 }
11543
11544
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_getc(&(temp_sub->type),f,true))
11545 {
11546 return qe_invalid;
11547 }
11548
11549
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_getc(&(temp_sub->pos),f,keepdata))
11550 {
11551 return qe_invalid;
11552 }
11553
11554
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(s_version < 5)
11555 {
11556 switch(temp_sub->pos)
11557 {
11558 case 0:
11559 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11560 break;
11561
11562 case 1:
11563 temp_sub->pos = sspUP;
11564 break;
11565
11566 case 2:
11567 temp_sub->pos = sspDOWN;
11568 break;
11569
11570 default:
11571 temp_sub->pos = 0;
11572 }
11573 }
11574
11575
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_igetw(&(temp_sub->x),f,keepdata))
11576 {
11577 return qe_invalid;
11578 }
11579
11580
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_igetw(&(temp_sub->y),f,keepdata))
11581 {
11582 return qe_invalid;
11583 }
11584
11585
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_igetw(&(temp_sub->w),f,keepdata))
11586 {
11587 return qe_invalid;
11588 }
11589
11590
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_igetw(&(temp_sub->h),f,keepdata))
11591 {
11592 return qe_invalid;
11593 }
11594
11595
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_getc(&(temp_sub->colortype1),f,keepdata))
11596 {
11597 return qe_invalid;
11598 }
11599
11600
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_igetw(&(temp_sub->color1),f,keepdata))
11601 {
11602 return qe_invalid;
11603 }
11604
11605
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_getc(&(temp_sub->colortype2),f,keepdata))
11606 {
11607 return qe_invalid;
11608 }
11609
11610
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_igetw(&(temp_sub->color2),f,keepdata))
11611 {
11612 return qe_invalid;
11613 }
11614
11615
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_getc(&(temp_sub->colortype3),f,keepdata))
11616 {
11617 return qe_invalid;
11618 }
11619
11620
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_igetw(&(temp_sub->color3),f,keepdata))
11621 {
11622 return qe_invalid;
11623 }
11624
11625
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_igetd(&(temp_sub->d1),f,keepdata))
11626 {
11627 return qe_invalid;
11628 }
11629
11630
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_igetd(&(temp_sub->d2),f,keepdata))
11631 {
11632 return qe_invalid;
11633 }
11634
11635
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_igetd(&(temp_sub->d3),f,keepdata))
11636 {
11637 return qe_invalid;
11638 }
11639
11640
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_igetd(&(temp_sub->d4),f,keepdata))
11641 {
11642 return qe_invalid;
11643 }
11644
11645
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_igetd(&(temp_sub->d5),f,keepdata))
11646 {
11647 return qe_invalid;
11648 }
11649
11650
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_igetd(&(temp_sub->d6),f,keepdata))
11651 {
11652 return qe_invalid;
11653 }
11654
11655
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_igetd(&(temp_sub->d7),f,keepdata))
11656 {
11657 return qe_invalid;
11658 }
11659
11660
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_igetd(&(temp_sub->d8),f,keepdata))
11661 {
11662 return qe_invalid;
11663 }
11664
11665
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_igetd(&(temp_sub->d9),f,keepdata))
11666 {
11667 return qe_invalid;
11668 }
11669
11670
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_igetd(&(temp_sub->d10),f,keepdata))
11671 {
11672 return qe_invalid;
11673 }
11674
11675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21481 times.
21481 if(s_version < 2)
11676 {
11677 if(!p_igetl(&(temp_sub->speed),f,keepdata))
11678 {
11679 return qe_invalid;
11680 }
11681
11682 if(!p_igetl(&(temp_sub->delay),f,keepdata))
11683 {
11684 return qe_invalid;
11685 }
11686
11687 if(!p_igetl(&(temp_sub->frame),f,keepdata))
11688 {
11689 return qe_invalid;
11690 }
11691 }
11692 else
11693 {
11694
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_getc(&(temp_sub->speed),f,keepdata))
11695 {
11696 return qe_invalid;
11697 }
11698
11699
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_getc(&(temp_sub->delay),f,keepdata))
11700 {
11701 return qe_invalid;
11702 }
11703
11704
1/2
✓ Branch 0 taken 21481 times.
✗ Branch 1 not taken.
21481 if(!p_igetw(&(temp_sub->frame),f,keepdata))
11705 {
11706 return qe_invalid;
11707 }
11708 }
11709
11710 21481 int32_t temp_size=0;
11711
11712 // bool deletets = false;
11713
4/4
✓ Branch 0 taken 9038 times.
✓ Branch 1 taken 1698 times.
✓ Branch 2 taken 10600 times.
✓ Branch 3 taken 145 times.
21481 switch(temp_sub->type)
11714 {
11715 case ssoTEXT:
11716 case ssoTEXTBOX:
11717 case ssoCURRENTITEMTEXT:
11718 case ssoCURRENTITEMCLASSTEXT:
11719 word temptempsize;
11720 /*uint8_t temp1;
11721 uint8_t temp2;
11722 temp2 = 0;
11723 if(!p_getc(&temp1,f,true))
11724 {
11725 return qe_invalid;
11726 }
11727 if(temp1)
11728 {
11729
11730 if(!p_getc(&temp2,f,true))
11731 {
11732 return qe_invalid;
11733 }
11734 }*/
11735
11736
1/2
✓ Branch 0 taken 1698 times.
✗ Branch 1 not taken.
1698 if(!p_igetw(&temptempsize,f,true))
11737 {
11738 return qe_invalid;
11739 }
11740
11741 //temptempsize = temp1 + (temp2 << 8);
11742 1698 temp_size = (int32_t)temptempsize;
11743
11744 //if(temp_sub->dp1!=NULL) delete[] temp_sub->dp1;
11745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1698 times.
1698 if(keepdata)
11746 {
11747 1698 uint32_t char_length = temp_size+1;
11748 1698 temp_sub->dp1 = new char[char_length]; //memory not freed
11749
11750 //deletets = true; //obsolete
11751 1698 }
11752
11753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1698 times.
1698 if(temp_size)
11754 {
11755
1/2
✓ Branch 0 taken 1698 times.
✗ Branch 1 not taken.
1698 if(!pfread(temp_sub->dp1,temp_size+1,f,keepdata))
11756 {
11757 return qe_invalid;
11758 }
11759 1698 }
11760
11761 1698 break;
11762
11763 case ssoLIFEMETER:
11764
1/2
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
145 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11765 temp_sub->d3 = 1;
11766
11767
1/2
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
145 if(!p_getc(&(temp_sub->dp1),f,keepdata))
11768 {
11769 return qe_invalid;
11770 }
11771
11772 145 break;
11773
11774
11775 case ssoCURRENTITEM:
11776
11777
1/2
✓ Branch 0 taken 9038 times.
✗ Branch 1 not taken.
9038 if(s_version < 6)
11778 {
11779 switch(temp_sub->d1)
11780 {
11781 case ssiBOMB:
11782 temp_sub->d1 = itype_bomb;
11783 break;
11784
11785 case ssiSWORD:
11786 temp_sub->d1 = itype_sword;
11787 break;
11788
11789 case ssiSHIELD:
11790 temp_sub->d1 = itype_shield;
11791 break;
11792
11793 case ssiCANDLE:
11794 temp_sub->d1 = itype_candle;
11795 break;
11796
11797 case ssiLETTER:
11798 temp_sub->d1 = itype_letter;
11799 break;
11800
11801 case ssiPOTION:
11802 temp_sub->d1 = itype_potion;
11803 break;
11804
11805 case ssiLETTERPOTION:
11806 temp_sub->d1 = itype_letterpotion;
11807 break;
11808
11809 case ssiBOW:
11810 temp_sub->d1 = itype_bow;
11811 break;
11812
11813 case ssiARROW:
11814 temp_sub->d1 = itype_arrow;
11815 break;
11816
11817 case ssiBOWANDARROW:
11818 temp_sub->d1 = itype_bowandarrow;
11819 break;
11820
11821 case ssiBAIT:
11822 temp_sub->d1 = itype_bait;
11823 break;
11824
11825 case ssiRING:
11826 temp_sub->d1 = itype_ring;
11827 break;
11828
11829 case ssiBRACELET:
11830 temp_sub->d1 = itype_bracelet;
11831 break;
11832
11833 case ssiMAP:
11834 temp_sub->d1 = itype_map;
11835 break;
11836
11837 case ssiCOMPASS:
11838 temp_sub->d1 = itype_compass;
11839 break;
11840
11841 case ssiBOSSKEY:
11842 temp_sub->d1 = itype_bosskey;
11843 break;
11844
11845 case ssiMAGICKEY:
11846 temp_sub->d1 = itype_magickey;
11847 break;
11848
11849 case ssiBRANG:
11850 temp_sub->d1 = itype_brang;
11851 break;
11852
11853 case ssiWAND:
11854 temp_sub->d1 = itype_wand;
11855 break;
11856
11857 case ssiRAFT:
11858 temp_sub->d1 = itype_raft;
11859 break;
11860
11861 case ssiLADDER:
11862 temp_sub->d1 = itype_ladder;
11863 break;
11864
11865 case ssiWHISTLE:
11866 temp_sub->d1 = itype_whistle;
11867 break;
11868
11869 case ssiBOOK:
11870 temp_sub->d1 = itype_book;
11871 break;
11872
11873 case ssiWALLET:
11874 temp_sub->d1 = itype_wallet;
11875 break;
11876
11877 case ssiSBOMB:
11878 temp_sub->d1 = itype_sbomb;
11879 break;
11880
11881 case ssiHCPIECE:
11882 temp_sub->d1 = itype_heartpiece;
11883 break;
11884
11885 case ssiAMULET:
11886 temp_sub->d1 = itype_amulet;
11887 break;
11888
11889 case ssiFLIPPERS:
11890 temp_sub->d1 = itype_flippers;
11891 break;
11892
11893 case ssiHOOKSHOT:
11894 temp_sub->d1 = itype_hookshot;
11895 break;
11896
11897 case ssiLENS:
11898 temp_sub->d1 = itype_lens;
11899 break;
11900
11901 case ssiHAMMER:
11902 temp_sub->d1 = itype_hammer;
11903 break;
11904
11905 case ssiBOOTS:
11906 temp_sub->d1 = itype_boots;
11907 break;
11908
11909 case ssiDIVINEFIRE:
11910 temp_sub->d1 = itype_divinefire;
11911 break;
11912
11913 case ssiDIVINEESCAPE:
11914 temp_sub->d1 = itype_divineescape;
11915 break;
11916
11917 case ssiDIVINEPROTECTION:
11918 temp_sub->d1 = itype_divineprotection;
11919 break;
11920
11921 case ssiQUIVER:
11922 temp_sub->d1 = itype_quiver;
11923 break;
11924
11925 case ssiBOMBBAG:
11926 temp_sub->d1 = itype_bombbag;
11927 break;
11928
11929 case ssiCBYRNA:
11930 temp_sub->d1 = itype_cbyrna;
11931 break;
11932
11933 case ssiROCS:
11934 temp_sub->d1 = itype_rocs;
11935 break;
11936
11937 case ssiHOVERBOOTS:
11938 temp_sub->d1 = itype_hoverboots;
11939 break;
11940
11941 case ssiSPINSCROLL:
11942 temp_sub->d1 = itype_spinscroll;
11943 break;
11944
11945 case ssiCROSSSCROLL:
11946 temp_sub->d1 = itype_crossscroll;
11947 break;
11948
11949 case ssiQUAKESCROLL:
11950 temp_sub->d1 = itype_quakescroll;
11951 break;
11952
11953 case ssiWHISPRING:
11954 temp_sub->d1 = itype_whispring;
11955 break;
11956
11957 case ssiCHARGERING:
11958 temp_sub->d1 = itype_chargering;
11959 break;
11960
11961 case ssiPERILSCROLL:
11962 temp_sub->d1 = itype_perilscroll;
11963 break;
11964
11965 case ssiWEALTHMEDAL:
11966 temp_sub->d1 = itype_wealthmedal;
11967 break;
11968
11969 case ssiHEARTRING:
11970 temp_sub->d1 = itype_heartring;
11971 break;
11972
11973 case ssiMAGICRING:
11974 temp_sub->d1 = itype_magicring;
11975 break;
11976
11977 case ssiSPINSCROLL2:
11978 temp_sub->d1 = itype_spinscroll2;
11979 break;
11980
11981 case ssiQUAKESCROLL2:
11982 temp_sub->d1 = itype_quakescroll2;
11983 break;
11984
11985 case ssiAGONY:
11986 temp_sub->d1 = itype_agony;
11987 break;
11988
11989 case ssiSTOMPBOOTS:
11990 temp_sub->d1 = itype_stompboots;
11991 break;
11992
11993 case ssiWHIMSICALRING:
11994 temp_sub->d1 = itype_whimsicalring;
11995 break;
11996
11997 case ssiPERILRING:
11998 temp_sub->d1 = itype_perilring;
11999 break;
12000
12001 default:
12002 temp_sub->d1 += itype_custom1 - ssiMAX;
12003 }
12004 }
12005
12006 //fall-through
12007 default:
12008
1/2
✓ Branch 0 taken 19638 times.
✗ Branch 1 not taken.
19638 if(!p_getc(&(temp_sub->dp1),f,keepdata))
12009 {
12010 return qe_invalid;
12011 }
12012
12013 19638 break;
12014 }
12015
12016
2/2
✓ Branch 0 taken 12970 times.
✓ Branch 1 taken 8511 times.
21481 if(s_version < 7)
12017 {
12018
3/3
✓ Branch 0 taken 7852 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 432 times.
8511 switch(temp_sub->type)
12019 {
12020 case ssoMAGICGAUGE:
12021 {
12022
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 192 times.
227 if(!temp_sub->d9)
12023 192 temp_sub->d9 = -1; //-1 now represents 'always'
12024 227 break;
12025 }
12026 case ssoLIFEGAUGE:
12027 432 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
12028 432 break;
12029 }
12030 8511 }
12031
12032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21481 times.
21481 if(keepdata)
12033 {
12034
3/3
✓ Branch 0 taken 1698 times.
✓ Branch 1 taken 18855 times.
✓ Branch 2 taken 928 times.
21481 switch(temp_sub->type)
12035 {
12036 case ssoTEXT:
12037 case ssoTEXTBOX:
12038 case ssoCURRENTITEMTEXT:
12039 case ssoCURRENTITEMCLASSTEXT:
12040
1/4
✓ Branch 0 taken 1698 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1698 if(custom_subscreen[i].objects[j].dp1 != NULL) delete[](char *)custom_subscreen[i].objects[j].dp1;
12041
12042 1698 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
12043 1698 custom_subscreen[i].objects[j].dp1 = NULL;
12044 1698 custom_subscreen[i].objects[j].dp1 = new char[temp_size+1];
12045 1698 strcpy((char*)custom_subscreen[i].objects[j].dp1,(char*)temp_sub->dp1);
12046 1698 break;
12047
12048 case ssoCOUNTER:
12049
1/2
✓ Branch 0 taken 928 times.
✗ Branch 1 not taken.
928 if(s_version<3)
12050 {
12051 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
12052 temp_sub->d8=0;
12053 }
12054
12055 default:
12056 19783 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
12057 19783 break;
12058 }
12059
12060 21481 strcpy(custom_subscreen[i].name, tempname);
12061 21481 custom_subscreen[i].ss_type = temp_ss;
12062 21481 }
12063 21481 }
12064
12065
2/2
✓ Branch 0 taken 3255319 times.
✓ Branch 1 taken 12800 times.
3268119 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
12066 {
12067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3255319 times.
3255319 if(keepdata)
12068 {
12069 //clear all unused object in this subscreen -DD
12070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3255319 times.
3255319 switch(custom_subscreen[i].objects[j].type)
12071 {
12072 case ssoTEXT:
12073 case ssoTEXTBOX:
12074 case ssoCURRENTITEMTEXT:
12075 case ssoCURRENTITEMCLASSTEXT:
12076 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
12077
12078 //fall through
12079 default:
12080 3255319 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
12081 3255319 break;
12082 }
12083 3255319 }
12084 3255319 }
12085
12086 12800 return 0;
12087 12800 }
12088
12089 2944 void reset_subscreen(subscreen_group *tempss)
12090 {
12091
2/2
✓ Branch 0 taken 753664 times.
✓ Branch 1 taken 2944 times.
756608 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
12092 {
12093
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 753522 times.
753664 switch(tempss->objects[i].type)
12094 {
12095 case ssoTEXT:
12096 case ssoTEXTBOX:
12097 case ssoCURRENTITEMTEXT:
12098 case ssoCURRENTITEMCLASSTEXT:
12099
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 142 times.
✗ Branch 3 not taken.
142 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
12100
12101 //fall through
12102 default:
12103 753664 memset(&tempss->objects[i],0,sizeof(subscreen_object));
12104 753664 break;
12105 }
12106 753664 }
12107 2944 }
12108
12109 23 void reset_subscreens()
12110 {
12111
2/2
✓ Branch 0 taken 2944 times.
✓ Branch 1 taken 23 times.
2967 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; ++i)
12112 {
12113 2944 reset_subscreen(&custom_subscreen[i]);
12114 2944 }
12115 23 }
12116
12117 23 int32_t setupsubscreens()
12118 {
12119 23 reset_subscreens();
12120 23 int32_t tempsubscreen=zinit.subscreen;
12121 subscreen_object *tempsub;
12122
12123
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(tempsubscreen>=ssdtMAX)
12124 {
12125 tempsubscreen=0;
12126 }
12127
12128
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
23 switch(tempsubscreen)
12129 {
12130 case ssdtOLD:
12131 case ssdtNEWSUBSCR:
12132 case ssdtREV2:
12133 case ssdtBSZELDA:
12134 case ssdtBSZELDAMODIFIED:
12135 case ssdtBSZELDAENHANCED:
12136 case ssdtBSZELDACOMPLETE:
12137 {
12138 23 tempsub = default_subscreen_active[tempsubscreen][0];
12139 int32_t i;
12140
12141
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1518 times.
✓ Branch 2 taken 1495 times.
✓ Branch 3 taken 23 times.
1518 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12142 {
12143
2/3
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 1431 times.
✗ Branch 2 not taken.
1495 switch(tempsub[i].type)
12144 {
12145 case ssoTEXT:
12146 case ssoTEXTBOX:
12147 case ssoCURRENTITEMTEXT:
12148 case ssoCURRENTITEMCLASSTEXT:
12149
1/4
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
64 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12150
12151 64 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12152 64 custom_subscreen[0].objects[i].dp1 = NULL;
12153 64 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12154 64 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12155 64 break;
12156
12157 case ssoLIFEMETER:
12158 {
12159 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12160
12161 if(get_bit(deprecated_rules, 12) != 0)
12162 custom_subscreen[0].objects[i].d3=1;
12163 else
12164 custom_subscreen[0].objects[i].d3=0;
12165
12166 break;
12167 }
12168 /*
12169 case ssoTRIFRAME:
12170 {
12171 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12172 custom_subscreen[0].objects[i].d1 = 8594;
12173 custom_subscreen[0].objects[i].d2 = 8;
12174 custom_subscreen[0].objects[i].d3 = 8771;
12175 custom_subscreen[0].objects[i].d4 = 8;
12176 custom_subscreen[0].objects[i].d5 = 1;
12177 custom_subscreen[0].objects[i].d6 = 1;
12178 break;
12179 }*/
12180
12181 default:
12182 1431 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12183 1431 break;
12184 }
12185 1495 }
12186
12187 23 custom_subscreen[0].ss_type=sstACTIVE;
12188 23 sprintf(custom_subscreen[0].name, "Active Subscreen (Triforce)");
12189 23 tempsub = default_subscreen_active[tempsubscreen][1];
12190
12191
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1518 times.
✓ Branch 2 taken 1495 times.
✓ Branch 3 taken 23 times.
1518 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12192 {
12193
2/3
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 1412 times.
✗ Branch 2 not taken.
1495 switch(tempsub[i].type)
12194 {
12195 case ssoTEXT:
12196 case ssoTEXTBOX:
12197 case ssoCURRENTITEMTEXT:
12198 case ssoCURRENTITEMCLASSTEXT:
12199
1/4
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
83 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12200
12201 83 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12202 83 custom_subscreen[1].objects[i].dp1 = NULL;
12203 83 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12204 83 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12205 83 break;
12206
12207 case ssoLIFEMETER:
12208 {
12209 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12210
12211 if(get_bit(deprecated_rules, 12) != 0)
12212 custom_subscreen[1].objects[i].d3=1;
12213 else
12214 custom_subscreen[1].objects[i].d3=0;
12215
12216 break;
12217 }
12218 /*
12219 case ssoTRIFRAME:
12220 {
12221 custom_subscreen[1].objects[i].d1 = 8594;
12222 custom_subscreen[1].objects[i].d2 = 8;
12223 custom_subscreen[1].objects[i].d3 = 8771;
12224 custom_subscreen[1].objects[i].d4 = 8;
12225 custom_subscreen[1].objects[i].d5 = 1;
12226 custom_subscreen[1].objects[i].d6 = 1;
12227 break;
12228 }*/
12229
12230 default:
12231 1412 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12232 1412 break;
12233 }
12234 1495 }
12235
12236 23 custom_subscreen[1].ss_type=sstACTIVE;
12237 23 sprintf(custom_subscreen[1].name, "Active Subscreen (Dungeon Map)");
12238 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12239 23 tempsub = default_subscreen_passive[tempsubscreen][0];
12240
12241
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 483 times.
✓ Branch 2 taken 460 times.
✓ Branch 3 taken 23 times.
483 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12242 {
12243
3/3
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 368 times.
✓ Branch 2 taken 23 times.
460 switch(tempsub[i].type)
12244 {
12245 case ssoTEXT:
12246 case ssoTEXTBOX:
12247 case ssoCURRENTITEMTEXT:
12248 case ssoCURRENTITEMCLASSTEXT:
12249
1/4
✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
69 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12250
12251 69 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12252 69 custom_subscreen[2].objects[i].dp1 = NULL;
12253 69 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12254 69 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12255 69 break;
12256
12257 case ssoLIFEMETER:
12258 {
12259 23 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12260
12261
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 16 times.
23 if(get_bit(deprecated_rules, 12) != 0)
12262 7 custom_subscreen[2].objects[i].d3=1;
12263 else
12264 16 custom_subscreen[2].objects[i].d3=0;
12265
12266 23 break;
12267 }
12268
12269 default:
12270 368 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12271 368 break;
12272 }
12273 460 }
12274
12275 23 custom_subscreen[2].ss_type=sstPASSIVE;
12276 23 sprintf(custom_subscreen[2].name, "Passive Subscreen (Magic)");
12277 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12278 23 tempsub = default_subscreen_passive[tempsubscreen][1];
12279
12280
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 460 times.
✓ Branch 2 taken 437 times.
✓ Branch 3 taken 23 times.
460 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12281 {
12282
3/3
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 345 times.
✓ Branch 2 taken 23 times.
437 switch(tempsub[i].type)
12283 {
12284 case ssoTEXT:
12285 case ssoTEXTBOX:
12286 case ssoCURRENTITEMTEXT:
12287 case ssoCURRENTITEMCLASSTEXT:
12288
1/4
✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
69 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12289
12290 69 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12291 69 custom_subscreen[3].objects[i].dp1 = NULL;
12292 69 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12293 69 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12294 69 break;
12295
12296 case ssoLIFEMETER:
12297 {
12298 23 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12299
12300
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 16 times.
23 if(get_bit(deprecated_rules, 12) != 0)
12301 7 custom_subscreen[3].objects[i].d3=1;
12302 else
12303 16 custom_subscreen[3].objects[i].d3=0;
12304
12305 23 break;
12306 }
12307
12308 default:
12309 345 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12310 345 break;
12311 }
12312 437 }
12313
12314 23 custom_subscreen[3].ss_type=sstPASSIVE;
12315 23 sprintf(custom_subscreen[3].name, "Passive Subscreen (No Magic)");
12316 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12317 23 break;
12318 }
12319
12320 case ssdtZ3:
12321 {
12322 tempsub = z3_active_a;
12323 int32_t i;
12324
12325 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12326 {
12327 switch(tempsub[i].type)
12328 {
12329 case ssoTEXT:
12330 case ssoTEXTBOX:
12331 case ssoCURRENTITEMTEXT:
12332 case ssoCURRENTITEMCLASSTEXT:
12333 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12334
12335 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12336 custom_subscreen[0].objects[i].dp1 = NULL;
12337 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12338 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12339 break;
12340
12341 case ssoLIFEMETER:
12342 {
12343 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12344
12345 if(get_bit(deprecated_rules, 12) != 0)
12346 custom_subscreen[0].objects[i].d3=1;
12347 else
12348 custom_subscreen[0].objects[i].d3=0;
12349
12350 break;
12351 }
12352
12353 default:
12354 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12355 break;
12356 }
12357 }
12358
12359 custom_subscreen[0].ss_type=sstACTIVE;
12360 // memset(&custom_subscreen[0].objects[i],0,sizeof(subscreen_object));
12361 tempsub = z3_active_ab;
12362
12363 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12364 {
12365 switch(tempsub[i].type)
12366 {
12367 case ssoTEXT:
12368 case ssoTEXTBOX:
12369 case ssoCURRENTITEMTEXT:
12370 case ssoCURRENTITEMCLASSTEXT:
12371 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12372
12373 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12374 custom_subscreen[1].objects[i].dp1 = NULL;
12375 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12376 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12377 break;
12378
12379 case ssoLIFEMETER:
12380 {
12381 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12382
12383 if(get_bit(deprecated_rules, 12) != 0)
12384 custom_subscreen[1].objects[i].d3=1;
12385 else
12386 custom_subscreen[1].objects[i].d3=0;
12387
12388 break;
12389 }
12390
12391 default:
12392 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12393 break;
12394 }
12395 }
12396
12397 custom_subscreen[1].ss_type=sstACTIVE;
12398 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12399 tempsub = z3_passive_a;
12400
12401 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12402 {
12403 switch(tempsub[i].type)
12404 {
12405 case ssoTEXT:
12406 case ssoTEXTBOX:
12407 case ssoCURRENTITEMTEXT:
12408 case ssoCURRENTITEMCLASSTEXT:
12409 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12410
12411 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12412 custom_subscreen[2].objects[i].dp1 = NULL;
12413 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12414 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12415 break;
12416
12417 case ssoLIFEMETER:
12418 {
12419 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12420
12421 if(get_bit(deprecated_rules, 12) != 0)
12422 custom_subscreen[2].objects[i].d3=1;
12423 else
12424 custom_subscreen[2].objects[i].d3=0;
12425
12426 break;
12427 }
12428
12429 default:
12430 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12431 break;
12432 }
12433 }
12434
12435 custom_subscreen[2].ss_type=sstPASSIVE;
12436 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12437 tempsub = z3_passive_ab;
12438
12439 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12440 {
12441 switch(tempsub[i].type)
12442 {
12443 case ssoTEXT:
12444 case ssoTEXTBOX:
12445 case ssoCURRENTITEMTEXT:
12446 case ssoCURRENTITEMCLASSTEXT:
12447 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12448
12449 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12450 custom_subscreen[3].objects[i].dp1 = NULL;
12451 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12452 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12453 break;
12454
12455 case ssoLIFEMETER:
12456 {
12457 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12458
12459 if(get_bit(deprecated_rules, 12) != 0)
12460 custom_subscreen[3].objects[i].d3=1;
12461 else
12462 custom_subscreen[3].objects[i].d3=0;
12463
12464 break;
12465 }
12466
12467 default:
12468 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12469 break;
12470 }
12471 }
12472
12473 custom_subscreen[3].ss_type=sstPASSIVE;
12474 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12475 break;
12476 }
12477 }
12478
12479
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 92 times.
115 for(int32_t i=0; i<4; ++i)
12480 {
12481 92 purge_blank_subscreen_objects(&custom_subscreen[i]);
12482 92 }
12483
12484 23 return 0;
12485 }
12486
12487 extern script_data *ffscripts[NUMSCRIPTFFC];
12488 extern script_data *itemscripts[NUMSCRIPTITEM];
12489 extern script_data *guyscripts[NUMSCRIPTGUYS];
12490 extern script_data *wpnscripts[NUMSCRIPTWEAPONS];
12491 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12492 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12493 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12494 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12495 extern script_data *playerscripts[NUMSCRIPTPLAYER];
12496 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12497 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12498 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12499 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12500 //script_data *wpnscripts[NUMSCRIPTWEAPONS]; //used only for old data
12501
12502
12503
12504 100 int32_t readffscript(PACKFILE *f, zquestheader *Header, bool keepdata)
12505 {
12506 int32_t dummy;
12507 100 word s_version=0, s_cversion=0, zmeta_version=0;
12508 100 byte numscripts=0;
12509 100 numscripts=numscripts; //to avoid unused variables warnings
12510 int32_t ret;
12511
12512 //section version info
12513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_igetw(&s_version,f,true))
12514 {
12515 return qe_invalid;
12516 }
12517
12518 100 FFCore.quest_format[vFFScript] = s_version;
12519
12520
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetw(&s_cversion,f,true))
12521 {
12522 return qe_invalid;
12523 }
12524
12525
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 25 times.
100 if(s_version >= 18)
12526 {
12527
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&zmeta_version,f,true))
12528 {
12529 return qe_invalid;
12530 }
12531 25 }
12532
12533 //al_trace("Scripts version %d\n", s_version);
12534 //section size
12535
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&dummy,f,true))
12536 {
12537 return qe_invalid;
12538 }
12539
12540 //ZScriptVersion::setVersion(s_version); ~this ideally, but there's no ZC/ZQuest defines...
12541 100 setZScriptVersion(s_version); //Lumped in zelda.cpp and in zquest.cpp as zquest can't link ZScriptVersion
12542 100 temp_ffscript_version = s_version;
12543 //miscQdata *the_misc;
12544
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 75 times.
100 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12545 100 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12546
12547 //finally... section data
12548
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 100 times.
51300 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12549 {
12550 51200 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
12551
12552
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(ret != 0) return qe_invalid;
12553 51200 }
12554
12555 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12556 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12557 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12558 * there was a version bump a week before a change that broke stuff.
12559 */
12560
6/8
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 25 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 25 times.
✓ Branch 7 taken 75 times.
100 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)) && keepdata)
12561 {
12562 75 set_bit(quest_rules,qr_SPRITE_JUMP_IS_TRUNCATED,1);
12563 75 }
12564
3/4
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 75 times.
100 if(s_version < 19 && keepdata)
12565 {
12566 75 set_bit(quest_rules,qr_FLUCTUATING_ENEMY_JUMP,1);
12567 75 }
12568
12569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(s_version > 1)
12570 {
12571
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 100 times.
25700 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12572 {
12573 25600 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
12574
12575
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(ret != 0) return qe_invalid;
12576 25600 }
12577
12578
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 100 times.
25700 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12579 {
12580 25600 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12581
12582
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(ret != 0) return qe_invalid;
12583 25600 }
12584
12585
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 100 times.
25700 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12586 {
12587 25600 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &wpnscripts[i], zmeta_version);
12588
12589
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(ret != 0) return qe_invalid;
12590 25600 }
12591
12592
12593
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 100 times.
25700 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12594 {
12595 25600 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12596
12597
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(ret != 0) return qe_invalid;
12598 25600 }
12599
12600
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 75 times.
100 if(s_version > 16)
12601 {
12602
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 25 times.
225 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12603 {
12604 200 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12605
12606
1/2
✓ Branch 0 taken 200 times.
✗ Branch 1 not taken.
200 if(ret != 0) return qe_invalid;
12607 200 }
12608 25 }
12609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 else if(s_version > 13)
12610 {
12611 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12612 {
12613 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12614
12615 if(ret != 0) return qe_invalid;
12616 }
12617
12618 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12619 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12620
12621 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12622 }
12623
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 else if(s_version > 4)
12624 {
12625
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 75 times.
375 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12626 {
12627 300 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12628
12629
1/2
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
300 if(ret != 0) return qe_invalid;
12630 300 }
12631
12632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12633
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12634
12635
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12636
12637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12638
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12639
12640
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12641
12642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12643
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 delete globalscripts[GLOBAL_SCRIPT_F6];
12644
12645
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12646
12647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12648
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12649
12650
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12651 75 }
12652 else
12653 {
12654 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12655 {
12656 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12657
12658 if(ret != 0) return qe_invalid;
12659 }
12660
12661 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12662 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12663
12664 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data();
12665
12666 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12667 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12668
12669 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12670
12671 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12672 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12673
12674 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12675
12676 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12677 delete globalscripts[GLOBAL_SCRIPT_F6];
12678
12679 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12680
12681 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12682 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12683
12684 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12685 }
12686
12687
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 75 times.
100 if(s_version > 10) //expanded the number of Player scripts to 5.
12688 {
12689
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 25 times.
150 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12690 {
12691 125 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12692
12693
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(ret != 0) return qe_invalid;
12694 125 }
12695 25 }
12696 else
12697 {
12698
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 75 times.
300 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12699 {
12700 225 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12701
12702
1/2
✓ Branch 0 taken 225 times.
✗ Branch 1 not taken.
225 if(ret != 0) return qe_invalid;
12703 225 }
12704
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(playerscripts[3] != NULL)
12705
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 delete playerscripts[3];
12706
12707
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 playerscripts[3] = new script_data();
12708
12709
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if(playerscripts[4] != NULL)
12710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 delete playerscripts[4];
12711
12712
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 playerscripts[4] = new script_data();
12713 }
12714
3/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 75 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
100 if(s_version > 8 && s_version < 10)
12715 {
12716
12717 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12718 {
12719 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12720
12721 if(ret != 0) return qe_invalid;
12722 }
12723 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12724 {
12725 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12726
12727 if(ret != 0) return qe_invalid;
12728 }
12729
12730 }
12731
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 25 times.
100 if(s_version >= 10)
12732 {
12733
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12734 {
12735 6400 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12736
12737
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(ret != 0) return qe_invalid;
12738 6400 }
12739
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12740 {
12741 6400 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12742
12743
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(ret != 0) return qe_invalid;
12744 6400 }
12745
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12746 {
12747 6400 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12748
12749
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(ret != 0) return qe_invalid;
12750 6400 }
12751
12752 25 }
12753
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 25 times.
100 if(s_version >=12)
12754 {
12755
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 25 times.
6425 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12756 {
12757 6400 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12758
12759
1/2
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
6400 if(ret != 0) return qe_invalid;
12760 6400 }
12761 25 }
12762
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 25 times.
100 if(s_version >=15)
12763 {
12764
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 25 times.
12825 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12765 {
12766 12800 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12767
12768
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(ret != 0) return qe_invalid;
12769 12800 }
12770 25 }
12771
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 25 times.
100 if(s_version >19)
12772 {
12773 25 word numgenscripts = NUMSCRIPTSGENERIC;
12774
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetw(&numgenscripts,f,true))
12775 {
12776 return qe_invalid;
12777 }
12778
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 25 times.
12825 for(int32_t i = 0; i < numgenscripts; i++)
12779 {
12780 12800 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12781
12782
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(ret != 0) return qe_invalid;
12783 12800 }
12784 25 }
12785
12786 /*
12787 else //Is this trip really necessary?
12788 {
12789 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12790 {
12791
12792 ewpnscripts[i] = NULL;
12793 }
12794 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12795 {
12796 dmapscripts[i] = NULL;
12797 }
12798 }
12799 */
12800
12801 100 }
12802
12803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(s_version > 2)
12804 {
12805 int32_t bufsize;
12806 100 p_igetl(&bufsize, f, true);
12807 100 char * buf = new char[bufsize+1];
12808 100 pfread(buf, bufsize, f, true);
12809 100 buf[bufsize]=0;
12810
12811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
12812
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 zScript = string(buf);
12813
12814
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 delete[] buf;
12815 word numffcbindings;
12816 100 p_igetw(&numffcbindings, f, true);
12817
12818
2/2
✓ Branch 0 taken 1369 times.
✓ Branch 1 taken 100 times.
1469 for(int32_t i=0; i<numffcbindings; i++)
12819 {
12820 word id;
12821 1369 p_igetw(&id, f, true);
12822 1369 p_igetl(&bufsize, f, true);
12823 1369 buf = new char[bufsize+1];
12824 1369 pfread(buf, bufsize, f, true);
12825 1369 buf[bufsize]=0;
12826
12827 //fix for buggy older saved quests -DD
12828
2/4
✓ Branch 0 taken 1369 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1369 times.
1369 if(keepdata && id < NUMSCRIPTFFC-1)
12829 1369 ffcmap[id].scriptname = buf;
12830
12831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1369 times.
1369 delete[] buf;
12832 1369 }
12833
12834 word numglobalbindings;
12835 100 p_igetw(&numglobalbindings, f, true);
12836
12837
2/2
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 100 times.
495 for(int32_t i=0; i<numglobalbindings; i++)
12838 {
12839 word id;
12840 395 p_igetw(&id, f, true);
12841 395 p_igetl(&bufsize, f, true);
12842 395 buf = new char[bufsize+1];
12843 395 pfread(buf, bufsize, f, true);
12844 395 buf[bufsize]=0;
12845
12846 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12847 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12848 // Ignore these. -DD
12849
4/6
✓ Branch 0 taken 395 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 395 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 154 times.
✓ Branch 5 taken 241 times.
395 if(keepdata && id >= 0 && id < NUMSCRIPTGLOBAL)
12850 {
12851 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12852
1/2
✓ Branch 0 taken 241 times.
✗ Branch 1 not taken.
241 if(strcmp(buf,"~Continue") == 0)
12853 {
12854 globalmap[id].scriptname = "";
12855
12856 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12857 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12858 }
12859 else
12860 {
12861 241 globalmap[id].scriptname = buf;
12862 }
12863 241 }
12864
12865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 delete[] buf;
12866 395 }
12867
12868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(s_version > 3)
12869 {
12870 word numitembindings;
12871 100 p_igetw(&numitembindings, f, true);
12872
12873
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 100 times.
189 for(int32_t i=0; i<numitembindings; i++)
12874 {
12875 word id;
12876 89 p_igetw(&id, f, true);
12877 89 p_igetl(&bufsize, f, true);
12878 89 buf = new char[bufsize+1];
12879 89 pfread(buf, bufsize, f, true);
12880 89 buf[bufsize]=0;
12881
12882 //fix this too
12883
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 89 times.
89 if(keepdata && id <NUMSCRIPTITEM-1)
12884 89 itemmap[id].scriptname = buf;
12885
12886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 delete[] buf;
12887 89 }
12888 100 }
12889 //(v9+)
12890
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 25 times.
100 if(s_version > 8)
12891 {
12892 //npc scripts
12893 word numnpcbindings;
12894 25 p_igetw(&numnpcbindings, f, true);
12895
12896
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 25 times.
37 for(int32_t i=0; i<numnpcbindings; i++)
12897 {
12898 word id;
12899 12 p_igetw(&id, f, true);
12900 12 p_igetl(&bufsize, f, true);
12901 12 buf = new char[bufsize+1];
12902 12 pfread(buf, bufsize, f, true);
12903 12 buf[bufsize]=0;
12904
12905 //fix this too
12906
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(keepdata && id <NUMSCRIPTGUYS-1)
12907 12 npcmap[id].scriptname = buf;
12908
12909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 delete[] buf;
12910 12 }
12911 //lweapon
12912 word numlwpnbindings;
12913 25 p_igetw(&numlwpnbindings, f, true);
12914
12915
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 25 times.
67 for(int32_t i=0; i<numlwpnbindings; i++)
12916 {
12917 word id;
12918 42 p_igetw(&id, f, true);
12919 42 p_igetl(&bufsize, f, true);
12920 42 buf = new char[bufsize+1];
12921 42 pfread(buf, bufsize, f, true);
12922 42 buf[bufsize]=0;
12923
12924 //fix this too
12925
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
42 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12926 42 lwpnmap[id].scriptname = buf;
12927
12928
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 delete[] buf;
12929 42 }
12930 //eweapon
12931 word numewpnbindings;
12932 25 p_igetw(&numewpnbindings, f, true);
12933
12934
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 25 times.
88 for(int32_t i=0; i<numewpnbindings; i++)
12935 {
12936 word id;
12937 63 p_igetw(&id, f, true);
12938 63 p_igetl(&bufsize, f, true);
12939 63 buf = new char[bufsize+1];
12940 63 pfread(buf, bufsize, f, true);
12941 63 buf[bufsize]=0;
12942
12943 //fix this too
12944
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
63 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12945 63 ewpnmap[id].scriptname = buf;
12946
12947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 delete[] buf;
12948 63 }
12949 //hero
12950 word numherobindings;
12951 25 p_igetw(&numherobindings, f, true);
12952
12953
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 25 times.
29 for(int32_t i=0; i<numherobindings; i++)
12954 {
12955 word id;
12956 4 p_igetw(&id, f, true);
12957 4 p_igetl(&bufsize, f, true);
12958 4 buf = new char[bufsize+1];
12959 4 pfread(buf, bufsize, f, true);
12960 4 buf[bufsize]=0;
12961
12962 //fix this too
12963
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(keepdata && id <NUMSCRIPTPLAYER-1)
12964 4 playermap[id].scriptname = buf;
12965
12966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 delete[] buf;
12967 4 }
12968 //dmaps
12969 word numdmapbindings;
12970 25 p_igetw(&numdmapbindings, f, true);
12971
12972
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 25 times.
39 for(int32_t i=0; i<numdmapbindings; i++)
12973 {
12974 word id;
12975 14 p_igetw(&id, f, true);
12976 14 p_igetl(&bufsize, f, true);
12977 14 buf = new char[bufsize+1];
12978 14 pfread(buf, bufsize, f, true);
12979 14 buf[bufsize]=0;
12980
12981 //fix this too
12982
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(keepdata && id <NUMSCRIPTSDMAP-1)
12983 14 dmapmap[id].scriptname = buf;
12984
12985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 delete[] buf;
12986 14 }
12987 //screen
12988 word numscreenbindings;
12989 25 p_igetw(&numscreenbindings, f, true);
12990
12991
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 25 times.
36 for(int32_t i=0; i<numscreenbindings; i++)
12992 {
12993 word id;
12994 11 p_igetw(&id, f, true);
12995 11 p_igetl(&bufsize, f, true);
12996 11 buf = new char[bufsize+1];
12997 11 pfread(buf, bufsize, f, true);
12998 11 buf[bufsize]=0;
12999
13000 //fix this too
13001
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
11 if(keepdata && id <NUMSCRIPTSDMAP-1)
13002 11 screenmap[id].scriptname = buf;
13003
13004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 delete[] buf;
13005 11 }
13006 25 }
13007
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 25 times.
100 if(s_version > 11)
13008 {
13009 word numspritebindings;
13010 25 p_igetw(&numspritebindings, f, true);
13011
13012
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 25 times.
35 for(int32_t i=0; i<numspritebindings; i++)
13013 {
13014 word id;
13015 10 p_igetw(&id, f, true);
13016 10 p_igetl(&bufsize, f, true);
13017 10 buf = new char[bufsize+1];
13018 10 pfread(buf, bufsize, f, true);
13019 10 buf[bufsize]=0;
13020
13021 //fix this too
13022
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 if(keepdata && id <NUMSCRIPTSDMAP-1)
13023 10 itemspritemap[id].scriptname = buf;
13024
13025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 delete[] buf;
13026 10 }
13027 25 }
13028
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 25 times.
100 if(s_version >= 15)
13029 {
13030 word numcombobindings;
13031 25 p_igetw(&numcombobindings, f, true);
13032
13033
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 25 times.
49 for(int32_t i=0; i<numcombobindings; i++)
13034 {
13035 word id;
13036 24 p_igetw(&id, f, true);
13037 24 p_igetl(&bufsize, f, true);
13038 24 buf = new char[bufsize+1];
13039 24 pfread(buf, bufsize, f, true);
13040 24 buf[bufsize]=0;
13041
13042 //fix this too
13043
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(keepdata && id <NUMSCRIPTSCOMBODATA-1)
13044 24 comboscriptmap[id].scriptname = buf;
13045
13046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 delete[] buf;
13047 24 }
13048 25 }
13049
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 25 times.
100 if(s_version > 19)
13050 {
13051 word numgenericbindings;
13052 25 p_igetw(&numgenericbindings, f, true);
13053
13054
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 25 times.
39 for(int32_t i=0; i<numgenericbindings; i++)
13055 {
13056 word id;
13057 14 p_igetw(&id, f, true);
13058 14 p_igetl(&bufsize, f, true);
13059 14 buf = new char[bufsize+1];
13060 14 pfread(buf, bufsize, f, true);
13061 14 buf[bufsize]=0;
13062
13063 //fix this too
13064
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(keepdata && id <NUMSCRIPTSGENERIC-1)
13065 14 genericmap[id].scriptname = buf;
13066
13067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 delete[] buf;
13068 14 }
13069 25 }
13070 100 }
13071
13072 100 return 0;
13073 100 }
13074
13075 109 void reset_scripts()
13076 {
13077 //OK, who spaced this? ;)
13078
2/2
✓ Branch 0 taken 55808 times.
✓ Branch 1 taken 109 times.
55917 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
13079 {
13080
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55808 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 55808 times.
55808 if(ffscripts[i]!=NULL) delete ffscripts[i];
13081 55808 }
13082
13083
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
13084 {
13085
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27904 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27904 times.
27904 if(itemscripts[i]!=NULL) delete itemscripts[i];
13086 27904 }
13087
13088
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
13089 {
13090
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27904 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27904 times.
27904 if(guyscripts[i]!=NULL) delete guyscripts[i];
13091 27904 }
13092
13093
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13094 {
13095
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27904 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27904 times.
27904 if(wpnscripts[i]!=NULL) delete wpnscripts[i];
13096 27904 }
13097
13098
13099
13100
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
13101 {
13102
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27904 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27904 times.
27904 if(screenscripts[i]!=NULL) delete screenscripts[i];
13103 27904 }
13104
13105
2/2
✓ Branch 0 taken 872 times.
✓ Branch 1 taken 109 times.
981 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13106 {
13107
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 872 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 872 times.
872 if(globalscripts[i]!=NULL) delete globalscripts[i];
13108 872 }
13109
13110
2/2
✓ Branch 0 taken 545 times.
✓ Branch 1 taken 109 times.
654 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
13111 {
13112
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 545 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 545 times.
545 if(playerscripts[i]!=NULL) delete playerscripts[i];
13113 545 }
13114
13115
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13116 {
13117
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27904 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27904 times.
27904 if(lwpnscripts[i]!=NULL) delete lwpnscripts[i];
13118 27904 }
13119
13120
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13121 {
13122
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27904 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27904 times.
27904 if(ewpnscripts[i]!=NULL) delete ewpnscripts[i];
13123 27904 }
13124
13125
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13126 {
13127
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27904 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27904 times.
27904 if(dmapscripts[i]!=NULL) delete dmapscripts[i];
13128 27904 }
13129
13130
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13131 {
13132
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27904 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27904 times.
27904 if(itemspritescripts[i]!=NULL) delete itemspritescripts[i];
13133 27904 }
13134
13135
2/2
✓ Branch 0 taken 55808 times.
✓ Branch 1 taken 109 times.
55917 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13136 {
13137
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55808 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 55808 times.
55808 if(comboscripts[i]!=NULL) delete comboscripts[i];
13138 55808 }
13139
13140 109 next_script_data_debug_id = 0;
13141
2/2
✓ Branch 0 taken 55808 times.
✓ Branch 1 taken 109 times.
55917 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
13142 {
13143
3/4
✓ Branch 0 taken 16896 times.
✓ Branch 1 taken 38912 times.
✓ Branch 2 taken 38912 times.
✗ Branch 3 not taken.
55808 if(genericscripts[i]!=NULL) delete genericscripts[i];
13144
1/2
✓ Branch 0 taken 55808 times.
✗ Branch 1 not taken.
55808 genericscripts[i] = new script_data();
13145 55808 }
13146
13147
2/2
✓ Branch 0 taken 55808 times.
✓ Branch 1 taken 109 times.
55917 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
13148 {
13149
1/2
✓ Branch 0 taken 55808 times.
✗ Branch 1 not taken.
55808 ffscripts[i] = new script_data();
13150 55808 }
13151
13152
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
13153 {
13154
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 itemscripts[i] = new script_data();
13155 27904 }
13156
13157
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
13158 {
13159
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 guyscripts[i] = new script_data();
13160 27904 }
13161
13162
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13163 {
13164
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 wpnscripts[i] = new script_data();
13165 27904 }
13166
13167
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
13168 {
13169
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 screenscripts[i] = new script_data();
13170 27904 }
13171
13172
2/2
✓ Branch 0 taken 872 times.
✓ Branch 1 taken 109 times.
981 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13173 {
13174
1/2
✓ Branch 0 taken 872 times.
✗ Branch 1 not taken.
872 globalscripts[i] = new script_data();
13175 872 }
13176
13177
2/2
✓ Branch 0 taken 545 times.
✓ Branch 1 taken 109 times.
654 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
13178 {
13179
1/2
✓ Branch 0 taken 545 times.
✗ Branch 1 not taken.
545 playerscripts[i] = new script_data();
13180 545 }
13181
13182
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13183 {
13184
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 lwpnscripts[i] = new script_data();
13185 27904 }
13186
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13187 {
13188
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 ewpnscripts[i] = new script_data();
13189 27904 }
13190
13191
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13192 {
13193
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 dmapscripts[i] = new script_data();
13194 27904 }
13195
2/2
✓ Branch 0 taken 27904 times.
✓ Branch 1 taken 109 times.
28013 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13196 {
13197
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 itemspritescripts[i] = new script_data();
13198 27904 }
13199
2/2
✓ Branch 0 taken 55808 times.
✓ Branch 1 taken 109 times.
55917 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13200 {
13201
1/2
✓ Branch 0 taken 55808 times.
✗ Branch 1 not taken.
55808 comboscripts[i] = new script_data();
13202 55808 }
13203 109 }
13204
13205 extern script_command command_list[];
13206 205650 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, bool keepdata, int32_t , word s_version, word , script_data **script, word zmeta_version)
13207 {
13208 //Please also update loadquest() when modifying this method -DD
13209 205650 char b33[34] = {0};
13210 205650 b33[33] = 0;
13211 205650 ffscript temp_script;
13212 205650 int32_t num_commands=1000;
13213
13214
1/2
✓ Branch 0 taken 205650 times.
✗ Branch 1 not taken.
205650 if(s_version>=2)
13215 {
13216
2/4
✓ Branch 0 taken 205650 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 205650 times.
✗ Branch 3 not taken.
205650 if(!p_igetl(&num_commands,f,true))
13217 {
13218 return qe_invalid;
13219 }
13220 205650 }
13221
13222
1/2
✓ Branch 0 taken 205650 times.
✗ Branch 1 not taken.
205650 if(keepdata)
13223 {
13224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205650 times.
205650 if((*script) != NULL) //Surely we want to do this regardless of keepdata? //No, we don't -V
13225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205650 times.
205650 delete (*script);
13226
2/4
✓ Branch 0 taken 205650 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 205650 times.
✗ Branch 3 not taken.
205650 (*script) = new script_data(num_commands);
13227 205650 }
13228
2/2
✓ Branch 0 taken 89925 times.
✓ Branch 1 taken 115725 times.
205650 if(s_version >= 16)
13229 {
13230
1/2
✓ Branch 0 taken 89925 times.
✗ Branch 1 not taken.
89925 zasm_meta temp_meta;
13231
13232
2/4
✓ Branch 0 taken 89925 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89925 times.
✗ Branch 3 not taken.
89925 if(!p_igetw(&(temp_meta.zasm_v),f,true))
13233 {
13234 return qe_invalid;
13235 }
13236
13237
2/4
✓ Branch 0 taken 89925 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89925 times.
✗ Branch 3 not taken.
89925 if(!p_igetw(&(temp_meta.meta_v),f,true))
13238 {
13239 return qe_invalid;
13240 }
13241
13242
2/4
✓ Branch 0 taken 89925 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89925 times.
✗ Branch 3 not taken.
89925 if(!p_igetw(&(temp_meta.ffscript_v),f,true))
13243 {
13244 return qe_invalid;
13245 }
13246
13247
2/4
✓ Branch 0 taken 89925 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89925 times.
✗ Branch 3 not taken.
89925 if(!p_getc(&(temp_meta.script_type),f,true))
13248 {
13249 return qe_invalid;
13250 }
13251
13252
2/2
✓ Branch 0 taken 719400 times.
✓ Branch 1 taken 89925 times.
809325 for(int32_t q = 0; q < 8; ++q)
13253 {
13254
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 661848 times.
719400 if(zmeta_version < 3)
13255 {
13256
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 1899216 times.
1956768 for(int32_t c = 0; c < 33; ++c)
13257 {
13258
2/4
✓ Branch 0 taken 1899216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1899216 times.
✗ Branch 3 not taken.
1899216 if(!p_getc(&(b33[c]),f,true))
13259 {
13260 return qe_invalid;
13261 }
13262 1899216 }
13263
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.run_idens[q].assign(b33);
13264 57552 }
13265 else
13266 {
13267
2/4
✓ Branch 0 taken 661848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 661848 times.
✗ Branch 3 not taken.
661848 if(!p_getcstr(&temp_meta.run_idens[q],f,true))
13268 {
13269 return qe_invalid;
13270 }
13271 }
13272 719400 }
13273
13274
2/2
✓ Branch 0 taken 89925 times.
✓ Branch 1 taken 719400 times.
809325 for(int32_t q = 0; q < 8; ++q)
13275 {
13276
2/4
✓ Branch 0 taken 719400 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 719400 times.
✗ Branch 3 not taken.
719400 if(!p_getc(&(temp_meta.run_types[q]),f,true))
13277 {
13278 return qe_invalid;
13279 }
13280 719400 }
13281
13282
2/4
✓ Branch 0 taken 89925 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89925 times.
✗ Branch 3 not taken.
89925 if(!p_getc(&(temp_meta.flags),f,true))
13283 {
13284 return qe_invalid;
13285 }
13286
13287
2/4
✓ Branch 0 taken 89925 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89925 times.
✗ Branch 3 not taken.
89925 if(!p_igetw(&(temp_meta.compiler_v1),f,true))
13288 {
13289 return qe_invalid;
13290 }
13291
13292
2/4
✓ Branch 0 taken 89925 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89925 times.
✗ Branch 3 not taken.
89925 if(!p_igetw(&(temp_meta.compiler_v2),f,true))
13293 {
13294 return qe_invalid;
13295 }
13296
13297
2/4
✓ Branch 0 taken 89925 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89925 times.
✗ Branch 3 not taken.
89925 if(!p_igetw(&(temp_meta.compiler_v3),f,true))
13298 {
13299 return qe_invalid;
13300 }
13301
13302
2/4
✓ Branch 0 taken 89925 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89925 times.
✗ Branch 3 not taken.
89925 if(!p_igetw(&(temp_meta.compiler_v4),f,true))
13303 {
13304 return qe_invalid;
13305 }
13306
13307
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 82731 times.
89925 if(zmeta_version == 2)
13308 {
13309
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
13310 {
13311
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f,true))
13312 {
13313 return qe_invalid;
13314 }
13315 237402 }
13316
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.script_name.assign(b33);
13317
13318
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
13319 {
13320
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f,true))
13321 {
13322 return qe_invalid;
13323 }
13324 237402 }
13325
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.author.assign(b33);
13326 7194 }
13327
1/2
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
82731 else if(zmeta_version > 2)
13328 {
13329
2/4
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82731 times.
✗ Branch 3 not taken.
82731 if(!p_getcstr(&temp_meta.script_name,f,true))
13330 return qe_invalid;
13331
2/4
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82731 times.
✗ Branch 3 not taken.
82731 if(!p_getcstr(&temp_meta.author,f,true))
13332 return qe_invalid;
13333 82731 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13334
2/2
✓ Branch 0 taken 827310 times.
✓ Branch 1 taken 82731 times.
910041 for(auto q = 0; q < num_meta_attrib; ++q)
13335 {
13336
2/4
✓ Branch 0 taken 827310 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 827310 times.
✗ Branch 3 not taken.
827310 if(!p_getcstr(&temp_meta.attributes[q],f,true))
13337 return qe_invalid;
13338
2/4
✓ Branch 0 taken 827310 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 827310 times.
✗ Branch 3 not taken.
827310 if(!p_getwstr(&temp_meta.attributes_help[q],f,true))
13339 return qe_invalid;
13340 827310 }
13341
2/2
✓ Branch 0 taken 661848 times.
✓ Branch 1 taken 82731 times.
744579 for(auto q = 0; q < 8; ++q)
13342 {
13343
2/4
✓ Branch 0 taken 661848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 661848 times.
✗ Branch 3 not taken.
661848 if(!p_getcstr(&temp_meta.attribytes[q],f,true))
13344 return qe_invalid;
13345
2/4
✓ Branch 0 taken 661848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 661848 times.
✗ Branch 3 not taken.
661848 if(!p_getwstr(&temp_meta.attribytes_help[q],f,true))
13346 return qe_invalid;
13347 661848 }
13348
2/2
✓ Branch 0 taken 661848 times.
✓ Branch 1 taken 82731 times.
744579 for(auto q = 0; q < 8; ++q)
13349 {
13350
2/4
✓ Branch 0 taken 661848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 661848 times.
✗ Branch 3 not taken.
661848 if(!p_getcstr(&temp_meta.attrishorts[q],f,true))
13351 return qe_invalid;
13352
2/4
✓ Branch 0 taken 661848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 661848 times.
✗ Branch 3 not taken.
661848 if(!p_getwstr(&temp_meta.attrishorts_help[q],f,true))
13353 return qe_invalid;
13354 661848 }
13355
2/2
✓ Branch 0 taken 1323696 times.
✓ Branch 1 taken 82731 times.
1406427 for(auto q = 0; q < 16; ++q)
13356 {
13357
2/4
✓ Branch 0 taken 1323696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1323696 times.
✗ Branch 3 not taken.
1323696 if(!p_getcstr(&temp_meta.usrflags[q],f,true))
13358 return qe_invalid;
13359
2/4
✓ Branch 0 taken 1323696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1323696 times.
✗ Branch 3 not taken.
1323696 if(!p_getwstr(&temp_meta.usrflags_help[q],f,true))
13360 return qe_invalid;
13361 1323696 }
13362 82731 }
13363
2/2
✓ Branch 0 taken 82731 times.
✓ Branch 1 taken 7194 times.
89925 if(zmeta_version > 3)
13364 {
13365
2/2
✓ Branch 0 taken 661848 times.
✓ Branch 1 taken 82731 times.
744579 for(auto q = 0; q < 8; ++q)
13366 {
13367
2/4
✓ Branch 0 taken 661848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 661848 times.
✗ Branch 3 not taken.
661848 if(!p_getcstr(&temp_meta.initd[q],f,true))
13368 return qe_invalid;
13369
2/4
✓ Branch 0 taken 661848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 661848 times.
✗ Branch 3 not taken.
661848 if(!p_getwstr(&temp_meta.initd_help[q],f,true))
13370 return qe_invalid;
13371 661848 }
13372
2/2
✓ Branch 0 taken 661848 times.
✓ Branch 1 taken 82731 times.
744579 for(auto q = 0; q < 8; ++q)
13373 {
13374
2/4
✓ Branch 0 taken 661848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 661848 times.
✗ Branch 3 not taken.
661848 if(!p_getc(&temp_meta.initd_type[q],f,true))
13375 return qe_invalid;
13376 661848 }
13377 82731 }
13378 else
13379 {
13380
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
13381 {
13382
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.initd[q] = temp_meta.run_idens[q];
13383 57552 }
13384 }
13385
13386
1/2
✓ Branch 0 taken 89925 times.
✗ Branch 1 not taken.
89925 if(keepdata)
13387
1/2
✓ Branch 0 taken 89925 times.
✗ Branch 1 not taken.
89925 (*script)->meta = temp_meta;
13388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89925 times.
89925 }
13389
13390
1/2
✓ Branch 0 taken 205650 times.
✗ Branch 1 not taken.
205650 temp_script.clear();
13391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20485394 times.
20485394 for(int32_t j=0; j<num_commands; j++)
13392 {
13393
2/4
✓ Branch 0 taken 20485394 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20485394 times.
✗ Branch 3 not taken.
20485394 if(!p_igetw(&(temp_script.command),f,true))
13394 {
13395 return qe_invalid;
13396 }
13397
13398
2/2
✓ Branch 0 taken 20279744 times.
✓ Branch 1 taken 205650 times.
20485394 if(temp_script.command == 0xFFFF)
13399 {
13400
1/2
✓ Branch 0 taken 205650 times.
✗ Branch 1 not taken.
205650 if(keepdata)
13401
1/2
✓ Branch 0 taken 205650 times.
✗ Branch 1 not taken.
205650 (*script)->zasm[j].clear();
13402 205650 break;
13403 }
13404 else
13405 {
13406
2/4
✓ Branch 0 taken 20279744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20279744 times.
✗ Branch 3 not taken.
20279744 if(!p_igetl(&(temp_script.arg1),f,keepdata))
13407 {
13408 return qe_invalid;
13409 }
13410
13411
2/4
✓ Branch 0 taken 20279744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20279744 times.
✗ Branch 3 not taken.
20279744 if(!p_igetl(&(temp_script.arg2),f,keepdata))
13412 {
13413 return qe_invalid;
13414 }
13415
13416
2/2
✓ Branch 0 taken 451731 times.
✓ Branch 1 taken 19828013 times.
20279744 if(s_version >= 21)
13417 {
13418 451731 uint32_t sz = 0;
13419
2/4
✓ Branch 0 taken 451731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 451731 times.
✗ Branch 3 not taken.
451731 if(!p_igetl(&sz,f,keepdata))
13420 {
13421 return qe_invalid;
13422 }
13423
2/2
✓ Branch 0 taken 1522 times.
✓ Branch 1 taken 450209 times.
451731 if(sz) //string found
13424 {
13425
1/2
✓ Branch 0 taken 1522 times.
✗ Branch 1 not taken.
1522 temp_script.strptr = new std::string();
13426 char dummy;
13427
2/2
✓ Branch 0 taken 115152 times.
✓ Branch 1 taken 1522 times.
116674 for(size_t q = 0; q < sz; ++q)
13428 {
13429
2/4
✓ Branch 0 taken 115152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115152 times.
✗ Branch 3 not taken.
115152 if(!p_getc(&dummy,f,keepdata))
13430 {
13431 return qe_invalid;
13432 }
13433
1/2
✓ Branch 0 taken 115152 times.
✗ Branch 1 not taken.
115152 temp_script.strptr->push_back(dummy);
13434 115152 }
13435 1522 }
13436
2/4
✓ Branch 0 taken 451731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 451731 times.
✗ Branch 3 not taken.
451731 if(!p_igetl(&sz,f,keepdata))
13437 {
13438 return qe_invalid;
13439 }
13440
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 451641 times.
451731 if(sz) //vector found
13441 {
13442
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 temp_script.vecptr = new std::vector<int32_t>();
13443 int32_t dummy;
13444
2/2
✓ Branch 0 taken 1311 times.
✓ Branch 1 taken 90 times.
1401 for(size_t q = 0; q < sz; ++q)
13445 {
13446
2/4
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1311 times.
✗ Branch 3 not taken.
1311 if(!p_igetl(&dummy,f,keepdata))
13447 {
13448 return qe_invalid;
13449 }
13450
1/2
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
1311 temp_script.vecptr->push_back(dummy);
13451 1311 }
13452 90 }
13453 451731 }
13454
13455
1/2
✓ Branch 0 taken 20279744 times.
✗ Branch 1 not taken.
20279744 if(keepdata)
13456 {
13457
1/2
✓ Branch 0 taken 20279744 times.
✗ Branch 1 not taken.
20279744 temp_script.give((*script)->zasm[j]);
13458 20279744 }
13459 }
13460
1/2
✓ Branch 0 taken 20279744 times.
✗ Branch 1 not taken.
20279744 temp_script.clear();
13461 20279744 }
13462
13463 205650 return 0;
13464 205650 }
13465
13466 extern SAMPLE customsfxdata[WAV_COUNT];
13467 extern uint8_t customsfxflag[WAV_COUNT>>3];
13468 extern int32_t sfxdat;
13469 extern DATAFILE *sfxdata;
13470 const char *old_sfx_string[Z35] =
13471 {
13472 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13473 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13474 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13475 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13476 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13477 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13478 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13479 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13480 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13481 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13482 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13483 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13484 };
13485 char *sfx_string[WAV_COUNT];
13486
13487 100 int32_t readsfx(PACKFILE *f, zquestheader *Header, bool keepdata)
13488 {
13489 //these are here to bypass compiler warnings about unused arguments
13490 100 Header=Header;
13491
13492 int32_t dummy;
13493 100 word s_version=0, s_cversion=0;
13494 //int32_t ret;
13495 SAMPLE temp_sample;
13496 100 temp_sample.loop_start=0;
13497 100 temp_sample.loop_end=0;
13498 100 temp_sample.param=0;
13499
13500 //section version info
13501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_igetw(&s_version,f,true))
13502 {
13503 return qe_invalid;
13504 }
13505
13506 100 FFCore.quest_format[vSFX] = s_version;
13507
13508 //al_trace("SFX version %d\n", s_version);
13509
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetw(&s_cversion,f,true))
13510 {
13511 return qe_invalid;
13512 }
13513
13514 //section size
13515
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&dummy,f,true))
13516 {
13517 return qe_invalid;
13518 }
13519
13520 /* HIGHLY UNORTHODOX UPDATING THING, by L
13521 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13522 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13523 * changing from 1 to 2.
13524 */
13525
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
100 if(s_version < 2 && keepdata)
13526 set_bit(quest_rules,qr_GOTOLESSNOTEQUAL,1);
13527
13528 /* End highly unorthodox updating thing */
13529
13530 100 int32_t wavcount = WAV_COUNT;
13531
13532
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(s_version < 6)
13533 wavcount = 128;
13534
13535 uint8_t tempflag[WAV_COUNT>>3];
13536
13537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(s_version < 4)
13538 {
13539 memset(tempflag, 0xFF, WAV_COUNT>>3);
13540 }
13541 else
13542 {
13543
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(s_version < 6)
13544 memset(tempflag, 0, WAV_COUNT>>3);
13545
13546
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 100 times.
3300 for(int32_t i=0; i<(wavcount>>3); i++)
13547 {
13548 3200 p_getc(&tempflag[i], f, true);
13549 3200 }
13550
13551 }
13552
13553
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(s_version>4)
13554 {
13555
2/2
✓ Branch 0 taken 25500 times.
✓ Branch 1 taken 100 times.
25600 for(int32_t i=1; i<WAV_COUNT; i++)
13556 {
13557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25500 times.
25500 if(keepdata)
13558 {
13559 25500 sprintf(sfx_string[i],"s%03d",i);
13560
13561
2/2
✓ Branch 0 taken 19500 times.
✓ Branch 1 taken 6000 times.
25500 if((i<Z35))
13562 6000 strcpy(sfx_string[i], old_sfx_string[i-1]);
13563 25500 }
13564
13565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25500 times.
25500 if(i>=wavcount)
13566 continue;
13567
2/2
✓ Branch 0 taken 2185 times.
✓ Branch 1 taken 23315 times.
25500 if(get_bit(tempflag, i-1))
13568 {
13569 char tempname[36];
13570
13571
1/2
✓ Branch 0 taken 2185 times.
✗ Branch 1 not taken.
2185 if(!pfread(tempname, 36, f, keepdata))
13572 {
13573 return qe_invalid;
13574 }
13575
13576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2185 times.
2185 if(keepdata)
13577 {
13578 2185 strcpy(sfx_string[i], tempname);
13579 2185 sfx_string[i][35] = 0; //Force NULL Termination
13580 2185 }
13581 2185 }
13582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23315 times.
23315 else if(keepdata)
13583 {
13584 23315 sprintf(sfx_string[i],"s%03d",i);
13585
13586
2/2
✓ Branch 0 taken 18855 times.
✓ Branch 1 taken 4460 times.
23315 if(i<Z35)
13587 4460 strcpy(sfx_string[i], old_sfx_string[i-1]);
13588 23315 sfx_string[i][35] = 0; //Force NULL Termination
13589 23315 }
13590 25500 }
13591 100 }
13592 else
13593 {
13594 if(keepdata)
13595 {
13596 for(int32_t i=1; i<WAV_COUNT; i++)
13597 {
13598 sprintf(sfx_string[i],"s%03d",i);
13599
13600 if(i<Z35)
13601 strcpy(sfx_string[i], old_sfx_string[i-1]);
13602 }
13603 }
13604 }
13605
13606 //finally... section data
13607
2/2
✓ Branch 0 taken 25500 times.
✓ Branch 1 taken 100 times.
25600 for(int32_t i=1; i<wavcount; i++)
13608 {
13609
2/2
✓ Branch 0 taken 2185 times.
✓ Branch 1 taken 23315 times.
25500 if(get_bit(tempflag, i-1))
13610 {
13611
13612
1/2
✓ Branch 0 taken 2185 times.
✗ Branch 1 not taken.
2185 if(!p_igetl(&dummy,f,true))
13613 {
13614 return qe_invalid;
13615 }
13616
13617 2185 (temp_sample.bits) = dummy;
13618
13619
1/2
✓ Branch 0 taken 2185 times.
✗ Branch 1 not taken.
2185 if(!p_igetl(&dummy,f,true))
13620 {
13621 return qe_invalid;
13622 }
13623
13624 2185 (temp_sample.stereo) = dummy;
13625
13626
1/2
✓ Branch 0 taken 2185 times.
✗ Branch 1 not taken.
2185 if(!p_igetl(&dummy,f,keepdata))
13627 {
13628 return qe_invalid;
13629 }
13630
13631 2185 (temp_sample.freq) = dummy;
13632
13633
1/2
✓ Branch 0 taken 2185 times.
✗ Branch 1 not taken.
2185 if(!p_igetl(&dummy,f,keepdata))
13634 {
13635 return qe_invalid;
13636 }
13637
13638 2185 (temp_sample.priority) = dummy;
13639
13640
1/2
✓ Branch 0 taken 2185 times.
✗ Branch 1 not taken.
2185 if(!p_igetl(&(temp_sample.len),f,true))
13641 {
13642 return qe_invalid;
13643 }
13644
13645
1/2
✓ Branch 0 taken 2185 times.
✗ Branch 1 not taken.
2185 if(!p_igetl(&(temp_sample.loop_start),f,keepdata))
13646 {
13647 return qe_invalid;
13648 }
13649
13650
1/2
✓ Branch 0 taken 2185 times.
✗ Branch 1 not taken.
2185 if(!p_igetl(&(temp_sample.loop_end),f,keepdata))
13651 {
13652 return qe_invalid;
13653 }
13654
13655
1/2
✓ Branch 0 taken 2185 times.
✗ Branch 1 not taken.
2185 if(!p_igetl(&(temp_sample.param),f,keepdata))
13656 {
13657 return qe_invalid;
13658 }
13659
13660 // al_trace("F%i: L%i\n",i,temp_sample.len);
13661 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13662 2185 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13663 2185 temp_sample.data = calloc(len,1);
13664
13665
1/2
✓ Branch 0 taken 2185 times.
✗ Branch 1 not taken.
2185 if(s_version < 3)
13666 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13667
13668 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2185 times.
2185 if(s_version < 2)
13670 {
13671 if(!pfread(temp_sample.data, len,f,keepdata))
13672 {
13673 return qe_invalid;
13674 }
13675 }
13676 else
13677 {
13678 //re-endianfy the data
13679 2185 int32_t wordstoread = len / sizeof(word);
13680
13681
2/2
✓ Branch 0 taken 67557588 times.
✓ Branch 1 taken 2185 times.
67559773 for(int32_t j=0; j<wordstoread; j++)
13682 {
13683 word temp;
13684
13685
1/2
✓ Branch 0 taken 67557588 times.
✗ Branch 1 not taken.
67557588 if(!p_igetw(&temp, f, keepdata))
13686 {
13687 return qe_invalid;
13688 }
13689
13690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67557588 times.
67557588 if(keepdata)
13691 67557588 ((word *)temp_sample.data)[j] = temp;
13692 67557588 }
13693 }
13694 2185 }
13695
2/2
✓ Branch 0 taken 4460 times.
✓ Branch 1 taken 18855 times.
23315 else if(i < Z35)
13696 {
13697 4460 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13698 4460 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13699 4460 set_bit(tempflag, i-1, 1);
13700 4460 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13701 4460 temp_sample.data = calloc(len,1);
13702 4460 memcpy(temp_sample.data, datsamp->data, len);
13703 4460 }
13704 18855 else continue;
13705
13706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6645 times.
6645 if(keepdata)
13707 {
13708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6645 times.
6645 if(customsfxdata[i].data!=NULL)
13709 {
13710 // delete [] customsfxdata[i].data;
13711 6645 free(customsfxdata[i].data);
13712 6645 }
13713
13714 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13715 6645 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13716 6645 customsfxdata[i].data = calloc(len2,1);
13717 6645 customsfxdata[i].bits = temp_sample.bits;
13718 6645 customsfxdata[i].stereo = temp_sample.stereo;
13719 6645 customsfxdata[i].freq = temp_sample.freq;
13720 6645 customsfxdata[i].priority = temp_sample.priority;
13721 6645 customsfxdata[i].len = temp_sample.len;
13722 6645 customsfxdata[i].loop_start = temp_sample.loop_start;
13723 6645 customsfxdata[i].loop_end = temp_sample.loop_end;
13724 6645 customsfxdata[i].param = temp_sample.param;
13725 6645 int32_t cpylen = len2;
13726
13727
1/2
✓ Branch 0 taken 6645 times.
✗ Branch 1 not taken.
6645 if(s_version<3)
13728 {
13729 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13730 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13731 }
13732
13733 6645 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13734 6645 }
13735
13736 6645 free(temp_sample.data);
13737 6645 }
13738
13739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
13740 100 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13741
13742 100 sfxdat=0;
13743 100 return 0;
13744 100 }
13745
13746 109 void setupsfx()
13747 {
13748
2/2
✓ Branch 0 taken 27795 times.
✓ Branch 1 taken 109 times.
27904 for(int32_t i=1; i<WAV_COUNT; i++)
13749 {
13750 27795 sprintf(sfx_string[i],"s%03d",i);
13751
13752
2/2
✓ Branch 0 taken 21255 times.
✓ Branch 1 taken 6540 times.
27795 if(i<Z35)
13753 {
13754 6540 strcpy(sfx_string[i], old_sfx_string[i-1]);
13755 6540 }
13756
13757 27795 memset(customsfxflag, 0, WAV_COUNT>>3);
13758
13759 27795 int32_t j=i;
13760
13761
2/2
✓ Branch 0 taken 6649 times.
✓ Branch 1 taken 21146 times.
27795 if(i>Z35)
13762 {
13763 21146 i=Z35;
13764 21146 }
13765
13766 27795 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13767
13768
2/2
✓ Branch 0 taken 8415 times.
✓ Branch 1 taken 19380 times.
27795 if(customsfxdata[j].data!=NULL)
13769 {
13770 // delete [] customsfxdata[j].data;
13771 19380 free(customsfxdata[j].data);
13772 19380 }
13773
13774 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13775 27795 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13776 27795 customsfxdata[j].bits = temp_sample->bits;
13777 27795 customsfxdata[j].stereo = temp_sample->stereo;
13778 27795 customsfxdata[j].freq = temp_sample->freq;
13779 27795 customsfxdata[j].priority = temp_sample->priority;
13780 27795 customsfxdata[j].len = temp_sample->len;
13781 27795 customsfxdata[j].loop_start = temp_sample->loop_start;
13782 27795 customsfxdata[j].loop_end = temp_sample->loop_end;
13783 27795 customsfxdata[j].param = temp_sample->param;
13784 27795 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13785 27795 i=j;
13786 27795 }
13787 109 }
13788
13789 extern char *guy_string[eMAXGUYS];
13790 extern const char *old_guy_string[OLDMAXGUYS];
13791
13792 109 int32_t readguys(PACKFILE *f, zquestheader *Header, bool keepdata)
13793 {
13794 dword dummy;
13795 word guy_cversion;
13796 109 word guyversion=0;
13797
13798
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 105 times.
109 if(Header->zelda_version >= 0x193)
13799 {
13800 //section version info
13801
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&guyversion,f,true))
13802 {
13803 return qe_invalid;
13804 }
13805
13806 105 FFCore.quest_format[vGuys] = guyversion;
13807
13808 //al_trace("Guys version %d\n", guyversion);
13809
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&guy_cversion,f,true))
13810 {
13811 return qe_invalid;
13812 }
13813 105 al_trace("Guy CVersion is: %d\n", guy_cversion);
13814 //section size
13815
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy,f,true))
13816 {
13817 return qe_invalid;
13818 }
13819 105 }
13820
13821
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
109 if(guyversion > 3)
13822 {
13823
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 100 times.
51300 for(int32_t i=0; i<MAXGUYS; i++)
13824 {
13825 char tempname[64];
13826
13827 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13828 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13829
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
51200 if(guyversion < 23 && i >= OLDBETAMAXGUYS && keepdata)
13830 {
13831 memset(tempname, 0, sizeof(char)*64);
13832 sprintf(tempname, "e%03d", i);
13833 strcpy(guy_string[i], tempname);
13834
13835 continue;
13836 }
13837
13838
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!pfread(tempname, 64, f, keepdata))
13839 {
13840 return qe_invalid;
13841 }
13842
13843 // Don't retain names of uneditable enemy entries!
13844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
51200 if(keepdata)
13845 {
13846 // for version upgrade to 2.5
13847
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
51200 if(guyversion < 23 && i >= 177)
13848 {
13849 // some of the older builds have names such as 'zz123',
13850 // (this order gets messed up with some eXXX and some zzXXX)
13851 // so let's update to the newer naming convection. -Gleeok
13852 char tmpbuf[64];
13853 memset(tmpbuf, 0, sizeof(char)*64);
13854 sprintf(tmpbuf, "zz%03d", i);
13855
13856 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13857 {
13858 memset(tempname, 0, sizeof(char)*64);
13859 sprintf(tempname, "e%03d", i);
13860 }
13861 }
13862
13863
6/6
✓ Branch 0 taken 17700 times.
✓ Branch 1 taken 33500 times.
✓ Branch 2 taken 16800 times.
✓ Branch 3 taken 900 times.
✓ Branch 4 taken 13900 times.
✓ Branch 5 taken 2900 times.
51200 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13864 {
13865 48300 strcpy(guy_string[i], tempname);
13866 48300 }
13867 else
13868 {
13869 2900 strcpy(guy_string[i],old_guy_string[i]);
13870 }
13871 51200 }
13872 51200 }
13873 100 }
13874 else
13875 {
13876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(keepdata)
13877 {
13878
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 9 times.
4617 for(int32_t i=0; i<eMAXGUYS; i++)
13879 {
13880 4608 sprintf(guy_string[i],"zz%03d",i);
13881 4608 }
13882
13883
2/2
✓ Branch 0 taken 1593 times.
✓ Branch 1 taken 9 times.
1602 for(int32_t i=0; i<OLDMAXGUYS; i++)
13884 {
13885 1593 strcpy(guy_string[i],old_guy_string[i]);
13886 1593 }
13887 9 }
13888 }
13889
13890
13891 //finally... section data
13892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(keepdata)
13893 {
13894 109 init_guys(guyversion); //using default data for now...
13895
13896 // Goriya guy fix
13897
3/6
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
109 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13898 {
13899
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 5 times.
9 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13900 {
13901 5 guysbuf[gGORIYA].tile=130;
13902 5 guysbuf[gGORIYA].e_tile=130;
13903 5 }
13904 9 }
13905 109 }
13906
13907
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
109 if(Header->zelda_version < 0x193)
13908 {
13909
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_bit(deprecated_rules,46))
13910 {
13911 guysbuf[eDODONGO].cset=14;
13912 guysbuf[eDODONGO].bosspal=spDIG;
13913 }
13914 4 }
13915 // Not sure when this first changed, but it's necessary for 2.10, at least
13916 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13917 //2.10 Fixes
13918
3/6
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
109 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13919 {
13920 9 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13921 9 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13922 9 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13923 9 guysbuf[eCENT1].misc3 = 1;
13924 9 guysbuf[eCENT2].misc3 = 1;
13925 9 }
13926
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
109 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13927 {
13928 109 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13929 109 }
13930
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
109 if(Header->zelda_version <= 0x210)
13931 {
13932 9 guysbuf[eGLEEOK1F].misc6 = 16;
13933 9 guysbuf[eGLEEOK2F].misc6 = 16;
13934 9 guysbuf[eGLEEOK3F].misc6 = 16;
13935 9 guysbuf[eGLEEOK4F].misc6 = 16;
13936
13937 9 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13938 9 guysbuf[eBATROBE].misc4 = 1;
13939 //guysbuf[eSUMMONER].misc4 = 1;
13940 9 guysbuf[eWWIZ].misc4 = 1;
13941 9 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13942 9 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13943 9 }
13944
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
109 if(Header->zelda_version == 0x190)
13945 {
13946 4 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13947 4 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13948 4 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13949 4 }
13950
13951 // The versions here may not be correct
13952 // zelda_version>=0x211 handled at guyversion<24
13953
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 105 times.
109 if(Header->zelda_version <= 0x190)
13954 {
13955 4 guysbuf[eCENT1].misc3 = 0;
13956 4 guysbuf[eCENT2].misc3 = 0;
13957 4 guysbuf[eMOLDORM].misc2 = 0;
13958 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13959 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13960 4 }
13961
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 5 times.
105 else if(Header->zelda_version <= 0x210)
13962 {
13963 5 guysbuf[eCENT1].misc3 = 1;
13964 5 guysbuf[eCENT2].misc3 = 1;
13965 5 guysbuf[eMOLDORM].misc2 = 0;
13966 5 }
13967
13968
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
109 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13969 {
13970 9 guysbuf[eKEESE1].misc16 = 120;
13971 9 guysbuf[eKEESE2].misc16 = 120;
13972 9 guysbuf[eKEESE3].misc16 = 120;
13973 9 guysbuf[eKEESETRIB].misc16 = 120;
13974 9 guysbuf[eKEESE1].misc17 = 16;
13975 9 guysbuf[eKEESE2].misc17 = 16;
13976 9 guysbuf[eKEESE3].misc17 = 16;
13977 9 guysbuf[eKEESETRIB].misc17 = 16;
13978
13979 9 guysbuf[ePEAHAT].misc16 = 80;
13980 9 guysbuf[ePEAHAT].misc17 = 16;
13981
13982 9 guysbuf[eGHINI2].misc16 = 120;
13983 9 guysbuf[eGHINI2].misc17 = 10;
13984
13985 9 }
13986
13987
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 100 times.
109 if(guyversion<=2)
13988 {
13989 9 return readherosprites2(f, guyversion==2?0:-1, 0, keepdata);
13990 }
13991
13992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(guyversion > 3)
13993 {
13994 guydata tempguy;
13995
13996
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 100 times.
51300 for(int32_t i=0; i<MAXGUYS; i++)
13997 {
13998
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
51200 if(guyversion < 23 && keepdata) // May 2012 : 512 max enemies
13999 {
14000 if(i >= OLDBETAMAXGUYS)
14001 {
14002 memset(&guysbuf[i], 0, sizeof(guydata));
14003 continue;
14004 }
14005 }
14006
14007 51200 memset(&tempguy, 0, sizeof(guydata));
14008
14009
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetl(&(tempguy.flags),f,keepdata))
14010 {
14011 return qe_invalid;
14012 }
14013
14014
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetl(&(tempguy.flags2),f,keepdata))
14015 {
14016 return qe_invalid;
14017 }
14018
14019
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 38400 times.
51200 if ( guyversion >= 36 ) //expanded tiles
14020 {
14021
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.tile),f,keepdata))
14022 {
14023 return qe_invalid;
14024 }
14025 12800 }
14026 else
14027 {
14028
1/2
✓ Branch 0 taken 38400 times.
✗ Branch 1 not taken.
38400 if(!p_igetw(&(tempguy.tile),f,keepdata))
14029 {
14030 return qe_invalid;
14031 }
14032 }
14033
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_getc(&(tempguy.width),f,keepdata))
14034 {
14035 return qe_invalid;
14036 }
14037
14038
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_getc(&(tempguy.height),f,keepdata))
14039 {
14040 return qe_invalid;
14041 }
14042
14043
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 38400 times.
51200 if ( guyversion >= 36 ) //expanded tiles
14044 {
14045
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.s_tile),f,keepdata))
14046 {
14047 return qe_invalid;
14048 }
14049 12800 }
14050 else
14051 {
14052
1/2
✓ Branch 0 taken 38400 times.
✗ Branch 1 not taken.
38400 if(!p_igetw(&(tempguy.s_tile),f,keepdata))
14053 {
14054 return qe_invalid;
14055 }
14056 }
14057
14058
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_getc(&(tempguy.s_width),f,keepdata))
14059 {
14060 return qe_invalid;
14061 }
14062
14063
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_getc(&(tempguy.s_height),f,keepdata))
14064 {
14065 return qe_invalid;
14066 }
14067
14068
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 38400 times.
51200 if ( guyversion >= 36 ) //expanded tiles
14069 {
14070
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.e_tile),f,keepdata))
14071 {
14072 return qe_invalid;
14073 }
14074 12800 }
14075 else
14076 {
14077
1/2
✓ Branch 0 taken 38400 times.
✗ Branch 1 not taken.
38400 if(!p_igetw(&(tempguy.e_tile),f,keepdata))
14078 {
14079 return qe_invalid;
14080 }
14081 }
14082
14083
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_getc(&(tempguy.e_width),f,keepdata))
14084 {
14085 return qe_invalid;
14086 }
14087
14088
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_getc(&(tempguy.e_height),f,keepdata))
14089 {
14090 return qe_invalid;
14091 }
14092
14093
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&(tempguy.hp),f,keepdata))
14094 {
14095 return qe_invalid;
14096 }
14097
14098
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&(tempguy.family),f,keepdata))
14099 {
14100 return qe_invalid;
14101 }
14102
14103
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
51200 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
14104 {
14105 if(get_bit(quest_rules,qr_NEWENEMYTILES))
14106 {
14107 tempguy.s_tile=tempguy.e_tile+120;
14108 tempguy.s_width=tempguy.e_width;
14109 tempguy.s_height=tempguy.e_height;
14110 }
14111 else tempguy.s_tile=860;
14112 }
14113
14114
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&(tempguy.cset),f,keepdata))
14115 {
14116 return qe_invalid;
14117 }
14118
14119
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&(tempguy.anim),f,keepdata))
14120 {
14121 return qe_invalid;
14122 }
14123
14124
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&(tempguy.e_anim),f,keepdata))
14125 {
14126 return qe_invalid;
14127 }
14128
14129
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&(tempguy.frate),f,keepdata))
14130 {
14131 return qe_invalid;
14132 }
14133
14134
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&(tempguy.e_frate),f,keepdata))
14135 {
14136 return qe_invalid;
14137 }
14138
14139
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(guyversion < 13) // April 2009
14140 {
14141 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
14142 {
14143 tempguy.frate *= 2;
14144 tempguy.e_frate *= 2;
14145 }
14146 }
14147
14148
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(guyversion < 14) // May 1 2009
14149 {
14150 if(tempguy.anim==a2FRMSLOW)
14151 {
14152 tempguy.anim=a2FRM;
14153 tempguy.frate *= 2;
14154 }
14155
14156 if(tempguy.e_anim==a2FRMSLOW)
14157 {
14158 tempguy.e_anim=a2FRM;
14159 tempguy.e_frate *= 2;
14160 }
14161
14162 if(tempguy.anim==aFLIPSLOW)
14163 {
14164 tempguy.anim=aFLIP;
14165 tempguy.frate *= 2;
14166 }
14167
14168 if(tempguy.e_anim==aFLIPSLOW)
14169 {
14170 tempguy.e_anim=aFLIP;
14171 tempguy.e_frate *= 2;
14172 }
14173
14174 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14175
14176 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14177
14178 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14179 {
14180 tempguy.anim=a4FRM4DIR;
14181 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14182 }
14183
14184 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14185 {
14186 tempguy.e_anim=a4FRM4DIR;
14187 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14188 }
14189 }
14190
14191
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&(tempguy.dp),f,keepdata))
14192 {
14193 return qe_invalid;
14194 }
14195
14196 //correction for guy fire
14197
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(guyversion < 6)
14198 {
14199 if(i == gFIRE)
14200 tempguy.dp = 2;
14201 }
14202
14203
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&(tempguy.wdp),f,keepdata))
14204 {
14205 return qe_invalid;
14206 }
14207
14208
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&(tempguy.weapon),f,keepdata))
14209 {
14210 return qe_invalid;
14211 }
14212
14213 //correction for bosses using triple, "rising" fireballs
14214
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(guyversion < 5)
14215 {
14216 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14217 i == eGOHMA3 || i == eGOHMA4)
14218 {
14219 if(tempguy.weapon == ewFireball)
14220 tempguy.weapon = ewFireball2;
14221 }
14222 }
14223
14224
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&(tempguy.rate),f,keepdata))
14225 {
14226 return qe_invalid;
14227 }
14228
14229
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&(tempguy.hrate),f,keepdata))
14230 {
14231 return qe_invalid;
14232 }
14233
14234
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&(tempguy.step),f,keepdata))
14235 {
14236 return qe_invalid;
14237 }
14238
14239 // HIGHLY UNORTHODOX UPDATING THING, part 2
14240
3/4
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 49664 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
51200 if(fixpolsvoice && tempguy.family==eePOLSV)
14241 {
14242 tempguy.step /= 2;
14243 }
14244
14245
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&(tempguy.homing),f,keepdata))
14246 {
14247 return qe_invalid;
14248 }
14249
14250
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&(tempguy.grumble),f,keepdata))
14251 {
14252 return qe_invalid;
14253 }
14254
14255
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&(tempguy.item_set),f,keepdata))
14256 {
14257 return qe_invalid;
14258 }
14259
14260
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14261 {
14262
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetl(&(tempguy.misc1),f,keepdata))
14263 {
14264 return qe_invalid;
14265 }
14266
14267
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetl(&(tempguy.misc2),f,keepdata))
14268 {
14269 return qe_invalid;
14270 }
14271
14272
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetl(&(tempguy.misc3),f,keepdata))
14273 {
14274 return qe_invalid;
14275 }
14276
14277
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetl(&(tempguy.misc4),f,keepdata))
14278 {
14279 return qe_invalid;
14280 }
14281
14282
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetl(&(tempguy.misc5),f,keepdata))
14283 {
14284 return qe_invalid;
14285 }
14286
14287
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetl(&(tempguy.misc6),f,keepdata))
14288 {
14289 return qe_invalid;
14290 }
14291
14292
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetl(&(tempguy.misc7),f,keepdata))
14293 {
14294 return qe_invalid;
14295 }
14296
14297
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetl(&(tempguy.misc8),f,keepdata))
14298 {
14299 return qe_invalid;
14300 }
14301
14302
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetl(&(tempguy.misc9),f,keepdata))
14303 {
14304 return qe_invalid;
14305 }
14306
14307
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetl(&(tempguy.misc10),f,keepdata))
14308 {
14309 return qe_invalid;
14310 }
14311 51200 }
14312 else
14313 {
14314 int16_t tempMisc;
14315
14316 if(!p_igetw(&tempMisc,f,keepdata))
14317 {
14318 return qe_invalid;
14319 }
14320
14321 tempguy.misc1=tempMisc;
14322
14323 if(!p_igetw(&tempMisc,f,keepdata))
14324 {
14325 return qe_invalid;
14326 }
14327
14328 tempguy.misc2=tempMisc;
14329
14330 if(!p_igetw(&tempMisc,f,keepdata))
14331 {
14332 return qe_invalid;
14333 }
14334
14335 tempguy.misc3=tempMisc;
14336
14337 if(!p_igetw(&tempMisc,f,keepdata))
14338 {
14339 return qe_invalid;
14340 }
14341
14342 tempguy.misc4=tempMisc;
14343
14344 if(!p_igetw(&tempMisc,f,keepdata))
14345 {
14346 return qe_invalid;
14347 }
14348
14349 tempguy.misc5=tempMisc;
14350
14351 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14352 {
14353 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
14354 tempguy.misc5 = 74;
14355 }
14356
14357 if(!p_igetw(&tempMisc,f,keepdata))
14358 {
14359 return qe_invalid;
14360 }
14361
14362 tempguy.misc6=tempMisc;
14363
14364 if(!p_igetw(&tempMisc,f,keepdata))
14365 {
14366 return qe_invalid;
14367 }
14368
14369 tempguy.misc7=tempMisc;
14370
14371 if(!p_igetw(&tempMisc,f,keepdata))
14372 {
14373 return qe_invalid;
14374 }
14375
14376 tempguy.misc8=tempMisc;
14377
14378 if(!p_igetw(&tempMisc,f,keepdata))
14379 {
14380 return qe_invalid;
14381 }
14382
14383 tempguy.misc9=tempMisc;
14384
14385 if(!p_igetw(&tempMisc,f,keepdata))
14386 {
14387 return qe_invalid;
14388 }
14389
14390 tempguy.misc10=tempMisc;
14391 }
14392
14393
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&(tempguy.bgsfx),f,keepdata))
14394 {
14395 return qe_invalid;
14396 }
14397
14398
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&(tempguy.bosspal),f,keepdata))
14399 {
14400 return qe_invalid;
14401 }
14402
14403
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetw(&(tempguy.extend),f,keepdata))
14404 {
14405 return qe_invalid;
14406 }
14407
14408 //! Enemy Defences
14409
14410 //If a 2.50 quest, use only the 2.5 defences.
14411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
51200 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14412 {
14413
2/2
✓ Branch 0 taken 972800 times.
✓ Branch 1 taken 51200 times.
1024000 for(int32_t j=0; j<edefLAST; j++)
14414 {
14415
1/2
✓ Branch 0 taken 972800 times.
✗ Branch 1 not taken.
972800 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14416 {
14417 return qe_invalid;
14418 }
14419 972800 }
14420 //then copy the generic script defence to all the new script defences
14421
14422 51200 }
14423
14424
14425
14426
14427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
51200 if(guyversion >= 18)
14428 {
14429
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_getc(&(tempguy.hitsfx),f,keepdata))
14430 {
14431 return qe_invalid;
14432 }
14433
14434
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_getc(&(tempguy.deadsfx),f,keepdata))
14435 {
14436 return qe_invalid;
14437 }
14438 51200 }
14439
14440
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(guyversion >= 22)
14441 {
14442
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetl(&(tempguy.misc11),f,keepdata))
14443 {
14444 return qe_invalid;
14445 }
14446
14447
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(!p_igetl(&(tempguy.misc12),f,keepdata))
14448 {
14449 return qe_invalid;
14450 }
14451 51200 }
14452 else if(guyversion >= 19)
14453 {
14454 int16_t tempMisc;
14455
14456 if(!p_igetw(&tempMisc,f,keepdata))
14457 {
14458 return qe_invalid;
14459 }
14460
14461 tempguy.misc11=tempMisc;
14462
14463 if(!p_igetw(&tempMisc,f,keepdata))
14464 {
14465 return qe_invalid;
14466 }
14467
14468 tempguy.misc12=tempMisc;
14469 }
14470
14471 //If a 2.54 or later quest, use all of the defences.
14472
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12800 times.
51200 if(guyversion > 24) // Add new guyversion conditional statement
14473 {
14474
2/2
✓ Branch 0 taken 281600 times.
✓ Branch 1 taken 12800 times.
294400 for(int32_t j=edefLAST; j<edefLAST255; j++)
14475 {
14476
1/2
✓ Branch 0 taken 281600 times.
✗ Branch 1 not taken.
281600 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14477 {
14478 return qe_invalid;
14479 }
14480 281600 }
14481 12800 }
14482
14483
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 38400 times.
51200 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14484 {
14485
2/2
✓ Branch 0 taken 384000 times.
✓ Branch 1 taken 38400 times.
422400 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14486 {
14487 384000 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14488 384000 }
14489 38400 }
14490
14491 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14492
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12800 times.
51200 if(guyversion > 25)
14493 {
14494
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.txsz),f,keepdata))
14495 {
14496 return qe_invalid;
14497 }
14498
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.tysz),f,keepdata))
14499 {
14500 return qe_invalid;
14501 }
14502
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.hxsz),f,keepdata))
14503 {
14504 return qe_invalid;
14505 }
14506
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.hysz),f,keepdata))
14507 {
14508 return qe_invalid;
14509 }
14510
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.hzsz),f,keepdata))
14511 {
14512 return qe_invalid;
14513 }
14514 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14515
14516 */
14517 12800 }
14518 //More Enemy Editor vars for 2.60
14519
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12800 times.
51200 if(guyversion > 26)
14520 {
14521
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.hxofs),f,keepdata))
14522 {
14523 return qe_invalid;
14524 }
14525
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.hyofs),f,keepdata))
14526 {
14527 return qe_invalid;
14528 }
14529
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.xofs),f,keepdata))
14530 {
14531 return qe_invalid;
14532 }
14533
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.yofs),f,keepdata))
14534 {
14535 return qe_invalid;
14536 }
14537
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.zofs),f,keepdata))
14538 {
14539 return qe_invalid;
14540 }
14541 12800 }
14542
14543
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 38400 times.
51200 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14544 {
14545 38400 tempguy.wpnsprite = 0;
14546 38400 }
14547
14548
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12800 times.
51200 if(guyversion > 27)
14549 {
14550
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.wpnsprite),f,keepdata))
14551 {
14552 return qe_invalid;
14553 }
14554 12800 }
14555
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 38400 times.
51200 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14556 {
14557 38400 tempguy.SIZEflags = 0;
14558 38400 }
14559
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12800 times.
51200 if(guyversion > 28)
14560 {
14561
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.SIZEflags),f,keepdata))
14562 {
14563 return qe_invalid;
14564 }
14565
14566 12800 }
14567
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 38400 times.
51200 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14568 {
14569 38400 tempguy.frozentile = 0;
14570 38400 tempguy.frozencset = 0;
14571 38400 tempguy.frozenclock = 0;
14572
2/2
✓ Branch 0 taken 384000 times.
✓ Branch 1 taken 38400 times.
422400 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14573 38400 }
14574
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12800 times.
51200 if(guyversion >= 30)
14575 {
14576
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.frozentile),f,keepdata))
14577 {
14578 return qe_invalid;
14579 }
14580
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.frozencset),f,keepdata))
14581 {
14582 return qe_invalid;
14583 }
14584
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.frozenclock),f,keepdata))
14585 {
14586 return qe_invalid;
14587 }
14588
2/2
✓ Branch 0 taken 128000 times.
✓ Branch 1 taken 12800 times.
140800 for ( int32_t q = 0; q < 10; q++ ) {
14589
1/2
✓ Branch 0 taken 128000 times.
✗ Branch 1 not taken.
128000 if(!p_igetw(&(tempguy.frozenmisc[q]),f,keepdata))
14590 {
14591 return qe_invalid;
14592 }
14593 128000 }
14594
14595 12800 }
14596
14597
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12800 times.
51200 if(guyversion >= 34)
14598 {
14599
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&(tempguy.firesfx),f,keepdata))
14600 {
14601 return qe_invalid;
14602 }
14603
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc16),f,keepdata))
14604 {
14605 return qe_invalid;
14606 }
14607
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc17),f,keepdata))
14608 {
14609 return qe_invalid;
14610 }
14611
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc18),f,keepdata))
14612 {
14613 return qe_invalid;
14614 }
14615
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc19),f,keepdata))
14616 {
14617 return qe_invalid;
14618 }
14619
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc20),f,keepdata))
14620 {
14621 return qe_invalid;
14622 }
14623
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc21),f,keepdata))
14624 {
14625 return qe_invalid;
14626 }
14627
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc22),f,keepdata))
14628 {
14629 return qe_invalid;
14630 }
14631
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc23),f,keepdata))
14632 {
14633 return qe_invalid;
14634 }
14635
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc24),f,keepdata))
14636 {
14637 return qe_invalid;
14638 }
14639
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc25),f,keepdata))
14640 {
14641 return qe_invalid;
14642 }
14643
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc26),f,keepdata))
14644 {
14645 return qe_invalid;
14646 }
14647
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc27),f,keepdata))
14648 {
14649 return qe_invalid;
14650 }
14651
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc28),f,keepdata))
14652 {
14653 return qe_invalid;
14654 }
14655
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc29),f,keepdata))
14656 {
14657 return qe_invalid;
14658 }
14659
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc30),f,keepdata))
14660 {
14661 return qe_invalid;
14662 }
14663
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc31),f,keepdata))
14664 {
14665 return qe_invalid;
14666 }
14667
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc32),f,keepdata))
14668 {
14669 return qe_invalid;
14670 }
14671
14672
2/2
✓ Branch 0 taken 409600 times.
✓ Branch 1 taken 12800 times.
422400 for ( int32_t q = 0; q < 32; q++ ) {
14673
1/2
✓ Branch 0 taken 409600 times.
✗ Branch 1 not taken.
409600 if(!p_igetl(&(tempguy.movement[q]),f,keepdata))
14674 {
14675 return qe_invalid;
14676 }
14677 409600 }
14678
2/2
✓ Branch 0 taken 409600 times.
✓ Branch 1 taken 12800 times.
422400 for ( int32_t q = 0; q < 32; q++ ) {
14679
1/2
✓ Branch 0 taken 409600 times.
✗ Branch 1 not taken.
409600 if(!p_igetl(&(tempguy.new_weapon[q]),f,keepdata))
14680 {
14681 return qe_invalid;
14682 }
14683 409600 }
14684
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&(tempguy.script),f,keepdata))
14685 {
14686 return qe_invalid;
14687 }
14688 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14689
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 12800 times.
115200 for ( int32_t q = 0; q < 8; q++ )
14690 {
14691
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_igetl(&(tempguy.initD[q]),f,keepdata))
14692 {
14693 return qe_invalid;
14694 }
14695 102400 }
14696
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 12800 times.
38400 for ( int32_t q = 0; q < 2; q++ )
14697 {
14698
1/2
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
25600 if(!p_igetl(&(tempguy.initA[q]),f,keepdata))
14699 {
14700 return qe_invalid;
14701 }
14702 25600 }
14703
14704 12800 }
14705
14706
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12800 times.
51200 if(guyversion >= 37)
14707 {
14708
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.editorflags),f,keepdata))
14709 {
14710 return qe_invalid;
14711 }
14712 12800 }
14713
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 38400 times.
51200 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14714
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12800 times.
51200 if(guyversion >= 38)
14715 {
14716
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc13),f,keepdata))
14717 {
14718 return qe_invalid;
14719 }
14720
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc14),f,keepdata))
14721 {
14722 return qe_invalid;
14723 }
14724
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetl(&(tempguy.misc15),f,keepdata))
14725 {
14726 return qe_invalid;
14727 }
14728
14729 12800 }
14730
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 38400 times.
51200 if ( guyversion < 38 )
14731 {
14732 38400 tempguy.misc13 = 0;
14733 38400 tempguy.misc14 = 0;
14734 38400 tempguy.misc15 = 0;
14735 38400 }
14736
14737
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12800 times.
51200 if ( guyversion >= 39 )
14738 {
14739
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 12800 times.
115200 for ( int32_t q = 0; q < 8; q++ )
14740 {
14741
2/2
✓ Branch 0 taken 6656000 times.
✓ Branch 1 taken 102400 times.
6758400 for ( int32_t w = 0; w < 65; w++ )
14742 {
14743
1/2
✓ Branch 0 taken 6656000 times.
✗ Branch 1 not taken.
6656000 if(!p_getc(&(tempguy.initD_label[q][w]),f,keepdata))
14744 {
14745 return qe_invalid;
14746 }
14747 6656000 }
14748
2/2
✓ Branch 0 taken 6656000 times.
✓ Branch 1 taken 102400 times.
6758400 for ( int32_t w = 0; w < 65; w++ )
14749 {
14750
1/2
✓ Branch 0 taken 6656000 times.
✗ Branch 1 not taken.
6656000 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f,keepdata))
14751 {
14752 return qe_invalid;
14753 }
14754 6656000 }
14755 102400 }
14756
14757
14758 12800 }
14759
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 38400 times.
51200 if ( guyversion < 39 ) //apply old InitD strings to both
14760 {
14761
2/2
✓ Branch 0 taken 307200 times.
✓ Branch 1 taken 38400 times.
345600 for ( int32_t q = 0; q < 8; q++ )
14762 {
14763 307200 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14764 307200 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14765 307200 }
14766 38400 }
14767
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12800 times.
51200 if ( guyversion >= 40 )
14768 {
14769
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_igetw(&(tempguy.weaponscript),f,keepdata))
14770 {
14771 return qe_invalid;
14772 }
14773 12800 }
14774
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 38400 times.
51200 if ( guyversion < 40 )
14775 {
14776 38400 tempguy.weaponscript = 0;
14777 38400 }
14778 //eweapon script InitD
14779
2/2
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12800 times.
51200 if ( guyversion >= 41 )
14780 {
14781
2/2
✓ Branch 0 taken 102400 times.
✓ Branch 1 taken 12800 times.
115200 for ( int32_t q = 0; q < 8; q++ )
14782 {
14783
1/2
✓ Branch 0 taken 102400 times.
✗ Branch 1 not taken.
102400 if(!p_igetl(&(tempguy.weap_initiald[q]),f,keepdata))
14784 {
14785 return qe_invalid;
14786 }
14787 102400 }
14788
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if ( guy_cversion < 4 )
14789 {
14790 if ( tempguy.family == eeKEESE )
14791 {
14792
14793 if ( !tempguy.misc1 )
14794 {
14795 tempguy.misc16 = 120;
14796 tempguy.misc17 = 16;
14797
14798 }
14799 }
14800 if ( tempguy.family == eePEAHAT )
14801 {
14802 tempguy.misc16 = 80;
14803 tempguy.misc17 = 16;
14804 }
14805
14806 if ( tempguy.family == eeGHINI )
14807 {
14808 tempguy.misc16 = 120;
14809 tempguy.misc17 = 10;
14810 }
14811
14812 }
14813 12800 }
14814
14815
14816
14817 //default weapon sprites (quest version < 2.54)
14818 //port over old defaults -Z
14819
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 38400 times.
51200 if(guyversion < 32)
14820 {
14821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38400 times.
38400 if ( tempguy.wpnsprite <= 0 )
14822 {
14823
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1281 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31939 times.
✓ Branch 4 taken 295 times.
✓ Branch 5 taken 306 times.
✓ Branch 6 taken 918 times.
✓ Branch 7 taken 483 times.
✓ Branch 8 taken 892 times.
✓ Branch 9 taken 78 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 133 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 357 times.
✓ Branch 14 taken 742 times.
✓ Branch 15 taken 104 times.
✓ Branch 16 taken 78 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 757 times.
38400 switch(tempguy.weapon)
14824 {
14825 case wNone:
14826 31939 tempguy.wpnsprite = 0; break;
14827
14828 case wSword:
14829 case wBeam:
14830 case wBrang:
14831 case wBomb:
14832 case wSBomb:
14833 case wLitBomb:
14834 case wLitSBomb:
14835 case wArrow:
14836 case wFire:
14837 case wWhistle:
14838 case wBait:
14839 case wWand:
14840 case wMagic:
14841 case wCatching:
14842 case wWind:
14843 case wRefMagic:
14844 case wRefFireball:
14845 case wRefRock:
14846 case wHammer:
14847 case wHookshot:
14848 case wHSHandle:
14849 case wHSChain:
14850 case wSSparkle:
14851 case wFSparkle:
14852 case wSmack:
14853 case wPhantom:
14854 case wCByrna:
14855 case wRefBeam:
14856 case wStomp:
14857 case lwMax:
14858 case wScript1:
14859 case wScript2:
14860 case wScript3:
14861 case wScript4:
14862 case wScript5:
14863 case wScript6:
14864 case wScript7:
14865 case wScript8:
14866 case wScript9:
14867 case wScript10:
14868 case wIce:
14869 //Cannot use any of these weapons yet.
14870 tempguy.wpnsprite = -1;
14871 break;
14872
14873 case wEnemyWeapons:
14874 1281 case ewFireball: tempguy.wpnsprite = 17; break;
14875
14876 295 case ewArrow: tempguy.wpnsprite = 19; break;
14877 306 case ewBrang: tempguy.wpnsprite = 4; break;
14878 918 case ewSword: tempguy.wpnsprite = 20; break;
14879 483 case ewRock: tempguy.wpnsprite = 18; break;
14880 892 case ewMagic: tempguy.wpnsprite = 21; break;
14881 78 case ewBomb: tempguy.wpnsprite = 78; break;
14882 18 case ewSBomb: tempguy.wpnsprite = 79; break;
14883 133 case ewLitBomb: tempguy.wpnsprite = 76; break;
14884 19 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14885 357 case ewFireTrail: tempguy.wpnsprite = 80; break;
14886 742 case ewFlame: tempguy.wpnsprite = 35; break;
14887 104 case ewWind: tempguy.wpnsprite = 36; break;
14888 78 case ewFlame2: tempguy.wpnsprite = 81; break;
14889 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14890 case ewIce: tempguy.wpnsprite = 83; break;
14891 757 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14892
14893
14894 default: break; //No assign.
14895 }
14896 38400 }
14897 38400 }
14898
14899 //default weapon fire sound (quest version < 2.54)
14900 //port over old defaults and zero new data. -Z
14901
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 38400 times.
51200 if(guyversion < 34)
14902 {
14903
2/2
✓ Branch 0 taken 1228800 times.
✓ Branch 1 taken 38400 times.
1267200 for ( int32_t q = 0; q < 32; q++ )
14904 {
14905 1228800 tempguy.movement[q] = 0;
14906 1228800 tempguy.new_weapon[q] = 0;
14907
14908 1228800 }
14909
14910 //NPC Script attributes.
14911 38400 tempguy.script = 0; //No scripted enemies existed. -Z
14912
2/2
✓ Branch 0 taken 307200 times.
✓ Branch 1 taken 38400 times.
345600 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14913
2/2
✓ Branch 0 taken 76800 times.
✓ Branch 1 taken 38400 times.
115200 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14914
14915 38400 tempguy.misc16 = 0;
14916 38400 tempguy.misc17 = 0;
14917 38400 tempguy.misc18 = 0;
14918 38400 tempguy.misc19 = 0;
14919 38400 tempguy.misc20 = 0;
14920 38400 tempguy.misc21 = 0;
14921 38400 tempguy.misc22 = 0;
14922 38400 tempguy.misc23 = 0;
14923 38400 tempguy.misc24 = 0;
14924 38400 tempguy.misc25 = 0;
14925 38400 tempguy.misc26 = 0;
14926 38400 tempguy.misc27 = 0;
14927 38400 tempguy.misc28 = 0;
14928 38400 tempguy.misc29 = 0;
14929 38400 tempguy.misc30 = 0;
14930 38400 tempguy.misc31 = 0;
14931 38400 tempguy.misc32 = 0;
14932
14933 //old default sounds
14934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38400 times.
38400 if ( tempguy.firesfx <= 0 )
14935 {
14936
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1281 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31939 times.
✓ Branch 4 taken 295 times.
✓ Branch 5 taken 306 times.
✓ Branch 6 taken 918 times.
✓ Branch 7 taken 483 times.
✓ Branch 8 taken 892 times.
✓ Branch 9 taken 78 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 133 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 357 times.
✓ Branch 14 taken 742 times.
✓ Branch 15 taken 104 times.
✓ Branch 16 taken 78 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 757 times.
38400 switch(tempguy.weapon)
14937 {
14938 case wNone:
14939 31939 tempguy.firesfx = 0; break;
14940
14941 case wSword:
14942 case wBeam:
14943 case wBrang:
14944 case wBomb:
14945 case wSBomb:
14946 case wLitBomb:
14947 case wLitSBomb:
14948 case wArrow:
14949 case wFire:
14950 case wWhistle:
14951 case wBait:
14952 case wWand:
14953 case wMagic:
14954 case wCatching:
14955 case wWind:
14956 case wRefMagic:
14957 case wRefFireball:
14958 case wRefRock:
14959 case wHammer:
14960 case wHookshot:
14961 case wHSHandle:
14962 case wHSChain:
14963 case wSSparkle:
14964 case wFSparkle:
14965 case wSmack:
14966 case wPhantom:
14967 case wCByrna:
14968 case wRefBeam:
14969 case wStomp:
14970 case lwMax:
14971 case wScript1:
14972 case wScript2:
14973 case wScript3:
14974 case wScript4:
14975 case wScript5:
14976 case wScript6:
14977 case wScript7:
14978 case wScript8:
14979 case wScript9:
14980 case wScript10:
14981 case wIce:
14982 //Cannot use any of these weapons yet.
14983 tempguy.firesfx = -1;
14984 break;
14985
14986 case wEnemyWeapons:
14987 1281 case ewFireball: tempguy.firesfx = 40; break;
14988
14989 295 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14990 306 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14991 918 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14992 483 case ewRock: tempguy.firesfx = 51; break;
14993 892 case ewMagic: tempguy.firesfx = 32; break;
14994 78 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14995 18 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14996 133 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14997 19 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14998 357 case ewFireTrail: tempguy.firesfx = 13; break;
14999 742 case ewFlame: tempguy.firesfx = 13; break;
15000 104 case ewWind: tempguy.firesfx = 32; break;
15001 78 case ewFlame2: tempguy.firesfx = 13; break;
15002 case ewFlame2Trail: tempguy.firesfx = 13; break;
15003 case ewIce: tempguy.firesfx = 44; break;
15004 757 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
15005
15006 //what about special attacks (e.g. summoning == 56)
15007 default: break; //No assign.
15008 }
15009 38400 }
15010 38400 }
15011
15012 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
15013
4/6
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 38400 times.
✓ Branch 2 taken 12800 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12800 times.
51200 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
15014 {
15015
2/2
✓ Branch 0 taken 3502 times.
✓ Branch 1 taken 34898 times.
38400 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
15016 38400 }
15017 //Keese and bat halt rates.
15018
3/4
✓ Branch 0 taken 38400 times.
✓ Branch 1 taken 12800 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38400 times.
51200 if ( guyversion < 42 && guy_cversion < 4 )
15019 {
15020
15021
2/2
✓ Branch 0 taken 37881 times.
✓ Branch 1 taken 519 times.
38400 if ( tempguy.family == eeKEESE )
15022 {
15023
15024
2/2
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 318 times.
519 if ( !tempguy.misc1 )
15025 {
15026 318 tempguy.misc16 = 120;
15027 318 tempguy.misc17 = 16;
15028
15029 318 }
15030 519 }
15031
2/2
✓ Branch 0 taken 38236 times.
✓ Branch 1 taken 164 times.
38400 if ( tempguy.family == eePEAHAT )
15032 {
15033 164 tempguy.misc16 = 80;
15034 164 tempguy.misc17 = 16;
15035 164 }
15036
2/2
✓ Branch 0 taken 38325 times.
✓ Branch 1 taken 75 times.
38400 if ( tempguy.family == eeGHINI )
15037 {
15038 75 tempguy.misc16 = 120;
15039 75 tempguy.misc17 = 10;
15040 75 }
15041
15042
15043 38400 }
15044
15045
15046 //miscellaneous other corrections
15047 //fix the mirror wizzrobe -DD
15048
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(guyversion < 7)
15049 {
15050 if(i == eMWIZ)
15051 {
15052 tempguy.misc2 = 0;
15053 tempguy.misc4 = 1;
15054 }
15055 }
15056
15057
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(guyversion < 8)
15058 {
15059 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
15060 {
15061 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
15062 tempguy.misc5 = 4; //neck length in segments
15063 tempguy.misc6 = 8; //neck offset from first body tile
15064 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
15065 tempguy.misc8 = 168; //head offset from first body tile
15066 tempguy.misc9 = 228; //flying head offset from first body tile
15067
15068 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
15069 {
15070 tempguy.misc6 += 10; //neck offset from first body tile
15071 tempguy.misc8 -= 12; //head offset from first body tile
15072 }
15073 }
15074 }
15075
15076
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(guyversion < 10) // December 2007 - Dodongo CSet fix
15077 {
15078 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
15079 tempguy.bosspal = spDIG;
15080 }
15081
15082
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(guyversion < 11) // December 2007 - Spinning Tile fix
15083 {
15084 if(tempguy.family==eeSPINTILE)
15085 {
15086 tempguy.flags |= guy_superman;
15087 tempguy.item_set = 0; // Don't drop items
15088 tempguy.step = 300;
15089 }
15090 }
15091
15092
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
15093 {
15094 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
15095 {
15096 if(tempguy.family==eeROPE)
15097 {
15098 tempguy.flags2 &= ~guy_flashing;
15099 }
15100 }
15101
15102 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
15103 {
15104 if(tempguy.family==eeBUBBLE)
15105 {
15106 tempguy.flags2 &= ~guy_flashing;
15107 }
15108 }
15109
15110 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
15111 {
15112 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
15113 {
15114 tempguy.flags2 |= guy_blinking;
15115 }
15116
15117 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
15118 {
15119 tempguy.flags2 |= guy_transparent;
15120 }
15121 }
15122 }
15123
15124
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
15125 {
15126 if(i==gFIRE)
15127 {
15128 tempguy.e_anim = aFLIP;
15129 tempguy.e_frate = 24;
15130 }
15131
15132 if(i==gFAIRY)
15133 {
15134 tempguy.e_anim = a2FRM;
15135 tempguy.e_frate = 16;
15136 }
15137 }
15138
15139
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
15140 {
15141 if(i==0) Z_message("Updating guys to version 16...\n");
15142
15143 update_guy_1(&tempguy);
15144
15145 if(i==eMPOLSV)
15146 {
15147 tempguy.defense[edefARROW] = edCHINK;
15148 tempguy.defense[edefMAGIC] = ed1HKO;
15149 tempguy.defense[edefREFMAGIC] = ed1HKO;
15150 }
15151 }
15152
15153
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(guyversion < 17) // December 2009
15154 {
15155 if(tempguy.family==eePROJECTILE)
15156 {
15157 tempguy.misc1 = 0;
15158 }
15159 }
15160
15161
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(guyversion < 18) // January 2010
15162 {
15163 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
15164 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
15165
15166 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
15167 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
15168
15169 if(tempguy.family == eeAQUA)
15170 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
15171 else if(tempguy.family == eeMANHAN)
15172 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
15173 else if(tempguy.family==eePATRA)
15174 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15175 else if(tempguy.family==eeGHOMA)
15176 {
15177 for(int32_t j=0; j<edefLAST; j++)
15178 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
15179
15180 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
15181
15182 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
15183
15184 tempguy.misc1--;
15185 }
15186 else if(tempguy.family == eeGLEEOK)
15187 {
15188 for(int32_t j=0; j<edefLAST; j++)
15189 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15190
15191 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
15192 }
15193 else if(tempguy.family == eeARMOS)
15194 {
15195 tempguy.family=eeWALK;
15196 tempguy.hrate = 0;
15197 tempguy.misc10 = tempguy.misc1;
15198 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
15199 tempguy.misc9 = e9tARMOS;
15200 }
15201 else if(tempguy.family == eeGHINI && !tempguy.misc1)
15202 {
15203 tempguy.family=eeWALK;
15204 tempguy.hrate = 0;
15205 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
15206 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
15207 }
15208
15209 // Spawn animation flags
15210 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
15211 tempguy.flags |= guy_fadeflicker;
15212 else
15213 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
15214 }
15215
15216
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(guyversion < 20) // April 2010
15217 {
15218 if(tempguy.family == eeTRAP)
15219 {
15220 tempguy.misc2 = tempguy.misc10;
15221
15222 if(tempguy.misc10>=1)
15223 {
15224 tempguy.misc1++;
15225 }
15226
15227 tempguy.misc10 = 0;
15228 }
15229
15230 // Bomb Blast fix
15231 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15232 tempguy.weapon = ewLitBomb;
15233 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15234 tempguy.weapon = ewLitSBomb;
15235 }
15236
15237
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(guyversion < 21) // September 2011
15238 {
15239 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
15240 {
15241 if(tempguy.family == eeKEESETRIB)
15242 {
15243 tempguy.family = eeKEESE;
15244 tempguy.misc2 = e2tKEESETRIB;
15245 tempguy.misc1 = 0;
15246 }
15247
15248 tempguy.rate = 2;
15249 tempguy.hrate = 8;
15250 tempguy.homing = 0;
15251 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
15252 }
15253 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
15254 {
15255 if(tempguy.family == eePEAHAT)
15256 {
15257 tempguy.rate = 4;
15258 tempguy.step = 62;
15259 }
15260 else
15261 tempguy.step = 25;
15262
15263 tempguy.hrate = 8;
15264 tempguy.homing = 0;
15265 }
15266 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
15267 {
15268 if(tempguy.family == eeMANHAN)
15269 tempguy.step=50;
15270
15271 tempguy.hrate = 16;
15272 tempguy.homing = 0;
15273 }
15274 else if(tempguy.family == eeGLEEOK)
15275 {
15276 tempguy.rate = 2;
15277 tempguy.homing = 0;
15278 tempguy.hrate = 9;
15279 tempguy.step=89;
15280 }
15281 else if(tempguy.family == eeGHINI)
15282 {
15283 tempguy.rate = 4;
15284 tempguy.hrate = 12;
15285 tempguy.step=62;
15286 tempguy.homing = 0;
15287 }
15288
15289 // Bigdig random rate fix
15290 if(tempguy.family==eeDIG && tempguy.misc10==1)
15291 {
15292 tempguy.rate = 2;
15293 }
15294 }
15295
15296
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if(guyversion < 24) // November 2012
15297 {
15298 if(tempguy.family==eeLANM)
15299 tempguy.misc3 = 1;
15300 else if(tempguy.family==eeMOLD)
15301 tempguy.misc2 = 0;
15302 }
15303
15304
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 38400 times.
51200 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15305 {
15306
2/2
✓ Branch 0 taken 648 times.
✓ Branch 1 taken 37752 times.
38400 if(tempguy.family!=eeDIG)
15307 {
15308 37752 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15309 37752 }
15310
15311 38400 }
15312 // does not seem to solve the issue!
15313
1/2
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
51200 if ( Header->zelda_version <= 0x210 )
15314 {
15315 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15316 if ( tempguy.family == eeDONGO )
15317 {
15318 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15319 }
15320 }
15321
15322
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 38400 times.
51200 if(guyversion >= 42)
15323 {
15324
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 1024 times.
12800 if(guyversion >= 47)
15325 {
15326
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.moveflags),f,keepdata))
15327 {
15328 return qe_invalid;
15329 }
15330 11776 }
15331 else
15332 {
15333 byte fl;
15334
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&fl,f,keepdata))
15335 {
15336 return qe_invalid;
15337 }
15338 1024 tempguy.moveflags = fl;
15339 }
15340 12800 }
15341 else
15342 {
15343
7/8
✓ Branch 0 taken 380 times.
✓ Branch 1 taken 30063 times.
✓ Branch 2 taken 1182 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 515 times.
✓ Branch 5 taken 274 times.
✓ Branch 6 taken 237 times.
✓ Branch 7 taken 5749 times.
38400 switch(tempguy.family)
15344 {
15345 //No gravity; floats over pits
15346 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15347 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15348 //Special (bosses, etc)
15349 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15350 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15351 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15352 30063 tempguy.moveflags = FLAG_CAN_PITWALK;
15353 30063 break;
15354 //No gravity, but falls in pits
15355 case eeLEV:
15356 515 tempguy.moveflags = FLAG_CAN_PITFALL;
15357 515 break;
15358 //Bosses that respect pits
15359 case eeDONGO:
15360 274 tempguy.moveflags = FLAG_OBEYS_GRAV;
15361 274 break;
15362 case eeLANM:
15363 237 tempguy.moveflags = 0;
15364 237 break;
15365 //Gravity, floats over pits
15366 case eeWIZZ: case eeWALLM: case eeGHINI:
15367 1182 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
15368 1182 break;
15369 //Gravity and falls in pits
15370 case eeWALK:
15371
4/4
✓ Branch 0 taken 5434 times.
✓ Branch 1 taken 315 times.
✓ Branch 2 taken 277 times.
✓ Branch 3 taken 5157 times.
5749 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
15372 592 break;
15373 [[fallthrough]];
15374 case eeOTHER:
15375 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15376 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15377 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15378 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15379 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15380 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15381 5537 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
15382 5537 }
15383 }
15384
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 38400 times.
51200 if(guyversion < 43)
15385 {
15386
2/2
✓ Branch 0 taken 31245 times.
✓ Branch 1 taken 7155 times.
38400 switch(tempguy.family)
15387 {
15388 //No gravity; floats over pits
15389 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15390 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15391 //Special (bosses, etc)
15392 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15393 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15394 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15395 case eeWIZZ: case eeWALLM: case eeGHINI:
15396 //Gravity, floats over pits
15397 31245 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15398 31245 break;
15399 }
15400 38400 }
15401
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 38400 times.
51200 if (guyversion < 44)
15402 {
15403
2/2
✓ Branch 0 taken 38037 times.
✓ Branch 1 taken 363 times.
38400 if ( tempguy.family == eeGHOMA )
15404 {
15405 363 tempguy.flags |= guy_fadeinstant;
15406 363 }
15407 38400 }
15408
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 38400 times.
51200 if (guyversion > 44)
15409 {
15410
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&(tempguy.spr_shadow),f,keepdata))
15411 {
15412 return qe_invalid;
15413 }
15414
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&(tempguy.spr_death),f,keepdata))
15415 {
15416 return qe_invalid;
15417 }
15418
1/2
✓ Branch 0 taken 12800 times.
✗ Branch 1 not taken.
12800 if(!p_getc(&(tempguy.spr_spawn),f,keepdata))
15419 {
15420 return qe_invalid;
15421 }
15422 12800 }
15423 else
15424 {
15425
2/2
✓ Branch 0 taken 38251 times.
✓ Branch 1 taken 149 times.
38400 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15426 38400 tempguy.spr_death = iwDeath;
15427 38400 tempguy.spr_spawn = iwSpawn;
15428 }
15429
15430
2/2
✓ Branch 0 taken 12800 times.
✓ Branch 1 taken 38400 times.
51200 if(guyversion < 46)
15431 {
15432
4/4
✓ Branch 0 taken 5749 times.
✓ Branch 1 taken 32651 times.
✓ Branch 2 taken 5434 times.
✓ Branch 3 taken 315 times.
38400 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15433 {
15434 315 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15435 315 }
15436 38400 }
15437
15438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51200 times.
51200 if(keepdata)
15439 {
15440 51200 guysbuf[i] = tempguy;
15441 51200 }
15442 51200 }
15443 100 }
15444
15445 100 return 0;
15446 109 }
15447
15448 void update_guy_1(guydata *tempguy) // November 2009
15449 {
15450 bool doesntcount = false;
15451 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15452
15453 switch(tempguy->family)
15454 {
15455 case 1: //eeWALK
15456 switch(tempguy->misc10)
15457 {
15458 case 0: //Stalfos
15459 if(tempguy->misc1==1) // Fires four projectiles at once
15460 tempguy->misc1=4;
15461
15462 break;
15463
15464 case 1: //Darknut
15465 goto darknuts;
15466 break;
15467 }
15468
15469 tempguy->misc10 = 0;
15470 break;
15471
15472 case 2: //eeSHOOT
15473 tempguy->family = eeWALK;
15474
15475 switch(tempguy->misc10)
15476 {
15477 case 0: //Octorok
15478 if(tempguy->misc1==1||tempguy->misc1==2)
15479 {
15480 tempguy->misc1=e1tFIREOCTO;
15481 tempguy->misc2=e2tFIREOCTO;
15482 }
15483 else tempguy->misc1 = 0;
15484
15485 tempguy->misc6=tempguy->misc4;
15486 tempguy->misc4=tempguy->misc3;
15487 tempguy->misc3=0;
15488 break;
15489
15490 case 1: // Moblin
15491 tempguy->misc1 = 0;
15492 break;
15493
15494 case 2: //Lynel
15495 tempguy->misc6=tempguy->misc1+1;
15496 tempguy->misc1=0;
15497 break;
15498
15499 case 3: //Stalfos 2
15500 if(tempguy->misc1==1) // Fires four projectiles at once
15501 tempguy->misc1=e1t4SHOTS;
15502 else tempguy->misc1 = 0;
15503
15504 break;
15505
15506 case 4: //Darknut 5
15507 darknuts:
15508 tempguy->defense[edefFIRE] = edIGNORE;
15509 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15510 tempguy->defense[edefHOOKSHOT] = 0;
15511 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15512 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15513
15514 if(tempguy->misc1==1)
15515 tempguy->misc1=2;
15516 else if(tempguy->misc1==2)
15517 {
15518 tempguy->misc4=tempguy->misc3;
15519 tempguy->misc3=tempguy->misc2;
15520 tempguy->misc2=e2tSPLIT;
15521 tempguy->misc1 = 0;
15522 }
15523 else tempguy->misc1 = 0;
15524
15525 tempguy->flags |= inv_front;
15526
15527 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15528 tempguy->flags |= guy_bkshield;
15529
15530 break;
15531 }
15532
15533 tempguy->misc10 = 0;
15534 break;
15535
15536 /*
15537 case 9: //eeARMOS
15538 tempguy->family = eeWALK;
15539 break;
15540 */
15541 case 11: //eeGEL
15542 case 33: //eeGELTRIB
15543 if(tempguy->family==33)
15544 {
15545 tempguy->misc4 = 1;
15546
15547 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15548 tempguy->misc3 = tempguy->misc2;
15549
15550 tempguy->misc2 = e2tTRIBBLE;
15551 }
15552 else
15553 {
15554 tempguy->misc4 = 0;
15555 tempguy->misc3 = 0;
15556 tempguy->misc2 = 0;
15557 }
15558
15559 tempguy->family = eeWALK;
15560
15561 if(tempguy->misc1)
15562 {
15563 tempguy->misc1=1;
15564 tempguy->weapon = ewFireTrail;
15565 }
15566
15567 break;
15568
15569 case 34: //eeZOLTRIB
15570 case 12: //eeZOL
15571 tempguy->misc4=tempguy->misc3;
15572 tempguy->misc3=tempguy->misc2;
15573 tempguy->family = eeWALK;
15574 tempguy->misc2=e2tSPLITHIT;
15575
15576 if(tempguy->misc1)
15577 {
15578 tempguy->misc1=1;
15579 tempguy->weapon = ewFireTrail;
15580 }
15581
15582 break;
15583
15584 case 13: //eeROPE
15585 tempguy->family = eeWALK;
15586 tempguy->misc9 = e9tROPE;
15587
15588 if(tempguy->misc1)
15589 {
15590 tempguy->misc4 = tempguy->misc3;
15591 tempguy->misc3 = tempguy->misc2;
15592 tempguy->misc2 = e2tBOMBCHU;
15593 }
15594
15595 tempguy->misc1 = 0;
15596 break;
15597
15598 case 14: //eeGORIYA
15599 tempguy->family = eeWALK;
15600
15601 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15602
15603 break;
15604
15605 case 17: //eeBUBBLE
15606 tempguy->family = eeWALK;
15607 tempguy->misc8 = tempguy->misc2;
15608 tempguy->misc7 = tempguy->misc1 + 1;
15609 tempguy->misc1 = tempguy->misc2 = 0;
15610
15611 //fallthrogh
15612 case eeTRAP:
15613 case eeROCK:
15614 doesntcount = true;
15615 break;
15616
15617 case 35: //eeVIRETRIB
15618 case 18: //eeVIRE
15619 tempguy->family = eeWALK;
15620 tempguy->misc4=tempguy->misc3;
15621 tempguy->misc3=tempguy->misc2;
15622 tempguy->misc2=e2tSPLITHIT;
15623 tempguy->misc9=e9tVIRE;
15624 break;
15625
15626 case 19: //eeLIKE
15627 tempguy->family = eeWALK;
15628 tempguy->misc7 = e7tEATITEMS;
15629 tempguy->misc8=95;
15630 break;
15631
15632 case 20: //eePOLSV
15633 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15634 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15635 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15636 tempguy->defense[edefARROW] = ed1HKO;
15637 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15638 tempguy->family = eeWALK;
15639 tempguy->misc9 = e9tPOLSVOICE;
15640 tempguy->rate = 4;
15641 tempguy->homing = 32;
15642 tempguy->hrate = 10;
15643 tempguy->grumble = 0;
15644 break;
15645
15646 case eeWIZZ:
15647 if(tempguy->misc4)
15648 {
15649 for(int32_t i=0; i < edefLAST; i++)
15650 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15651 }
15652 else
15653 {
15654 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15655 tempguy->defense[edefMAGIC] = edCHINK;
15656 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15657 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15658 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15659 }
15660
15661 break;
15662
15663 case eePEAHAT:
15664 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15665
15666 if(!(tempguy->flags & guy_bhit))
15667 tempguy->defense[edefBRANG] = edSTUNONLY;
15668
15669 break;
15670
15671 case eeLEV:
15672 tempguy->defense[edefSTOMP] = edCHINK;
15673 break;
15674 }
15675
15676 // Old flags
15677 if(tempguy->flags & guy_superman)
15678 {
15679 for(int32_t i = 0; i < edefLAST; i++)
15680 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15681 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15682 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15683 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15684 }
15685
15686 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15687
15688 if(doesntcount)
15689 tempguy->flags |= (guy_doesntcount);
15690 }
15691
15692
15693 186112 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
15694 {
15695 byte tempbyte, padding;
15696 int32_t extras, secretcombos;
15697 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 186112 times.
186112 if(!p_getc(&(temp_mapscr->valid),f,true))
15699 {
15700 return qe_invalid;
15701 }
15702
15703
15704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 186112 times.
186112 if(!p_getc(&(temp_mapscr->guy),f,true))
15705 {
15706 return qe_invalid;
15707 }
15708
15709
3/6
✓ Branch 0 taken 179248 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 179248 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15710 {
15711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f,true))
15712 {
15713 return qe_invalid;
15714 }
15715
15716 6864 temp_mapscr->str=tempbyte;
15717 6864 }
15718 else
15719 {
15720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 179248 times.
179248 if(!p_igetw(&(temp_mapscr->str),f,true))
15721 {
15722 return qe_invalid;
15723 }
15724 }
15725
15726
1/2
✓ Branch 0 taken 186112 times.
✗ Branch 1 not taken.
186112 if(!p_getc(&(temp_mapscr->room),f,true))
15727 {
15728 return qe_invalid;
15729 }
15730
15731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 186112 times.
186112 if(!p_getc(&(temp_mapscr->item),f,true))
15732 {
15733 return qe_invalid;
15734 }
15735
15736
3/6
✓ Branch 0 taken 151368 times.
✓ Branch 1 taken 34744 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 151368 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15737 {
15738 34744 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15739 34744 }
15740 else
15741 {
15742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151368 times.
151368 if(!p_getc(&(temp_mapscr->hasitem),f,true))
15743 return qe_invalid;
15744 }
15745
15746
2/4
✓ Branch 0 taken 179248 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
186112 if((Header->zelda_version < 0x192)||
15747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 179248 times.
179248 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15748 {
15749
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f,true))
15750 {
15751 return qe_invalid;
15752 }
15753 6864 }
15754
15755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 186112 times.
186112 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f,true))
15756 {
15757 return qe_invalid;
15758 }
15759
15760
2/2
✓ Branch 0 taken 179248 times.
✓ Branch 1 taken 6864 times.
186112 if(Header->zelda_version < 0x193)
15761 {
15762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f,true))
15763 {
15764 return qe_invalid;
15765 }
15766 6864 }
15767
15768
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 151368 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15769 {
15770
2/2
✓ Branch 0 taken 454104 times.
✓ Branch 1 taken 151368 times.
605472 for(int32_t i=1; i<4; i++)
15771 {
15772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454104 times.
454104 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
15773 {
15774 return qe_invalid;
15775 }
15776 454104 }
15777 151368 }
15778 else
15779 {
15780 34744 temp_mapscr->tilewarptype[1]=0;
15781 34744 temp_mapscr->tilewarptype[2]=0;
15782 34744 temp_mapscr->tilewarptype[3]=0;
15783 }
15784
15785
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 179248 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15786 {
15787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 179248 times.
179248 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
15788 {
15789 return qe_invalid;
15790 }
15791 179248 }
15792
15793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 186112 times.
186112 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f,true))
15794 {
15795 return qe_invalid;
15796 }
15797
15798 186112 temp_mapscr->warpreturnx[1]=0;
15799 186112 temp_mapscr->warpreturnx[2]=0;
15800 186112 temp_mapscr->warpreturnx[3]=0;
15801
15802
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 151368 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15803 {
15804
2/2
✓ Branch 0 taken 454104 times.
✓ Branch 1 taken 151368 times.
605472 for(int32_t i=1; i<4; i++)
15805 {
15806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454104 times.
454104 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
15807 {
15808 return qe_invalid;
15809 }
15810 454104 }
15811 151368 }
15812
15813
1/2
✓ Branch 0 taken 186112 times.
✗ Branch 1 not taken.
186112 if(!p_getc(&(temp_mapscr->warpreturny[0]),f,true))
15814 {
15815 return qe_invalid;
15816 }
15817
15818 186112 temp_mapscr->warpreturny[1]=0;
15819 186112 temp_mapscr->warpreturny[2]=0;
15820 186112 temp_mapscr->warpreturny[3]=0;
15821
15822
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 151368 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15823 {
15824
2/2
✓ Branch 0 taken 454104 times.
✓ Branch 1 taken 151368 times.
605472 for(int32_t i=1; i<4; i++)
15825 {
15826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454104 times.
454104 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
15827 {
15828 return qe_invalid;
15829 }
15830 454104 }
15831
15832
1/2
✓ Branch 0 taken 151368 times.
✗ Branch 1 not taken.
151368 if(version>=18)
15833 {
15834
1/2
✓ Branch 0 taken 151368 times.
✗ Branch 1 not taken.
151368 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
15835 {
15836 return qe_invalid;
15837 }
15838 151368 }
15839 else
15840 {
15841 byte temp;
15842
15843 if(!p_getc(&temp,f,true))
15844 {
15845 return qe_invalid;
15846 }
15847
15848 temp_mapscr->warpreturnc=temp<<8|temp;
15849 }
15850 151368 }
15851
15852
1/2
✓ Branch 0 taken 186112 times.
✗ Branch 1 not taken.
186112 if(!p_getc(&(temp_mapscr->stairx),f,true))
15853
15854 {
15855 return qe_invalid;
15856 }
15857
15858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 186112 times.
186112 if(!p_getc(&(temp_mapscr->stairy),f,true))
15859 {
15860 return qe_invalid;
15861 }
15862
15863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 186112 times.
186112 if(!p_getc(&(temp_mapscr->itemx),f,true))
15864 {
15865 return qe_invalid;
15866 }
15867
15868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 186112 times.
186112 if(!p_getc(&(temp_mapscr->itemy),f,true))
15869 {
15870 return qe_invalid;
15871 }
15872
15873
2/2
✓ Branch 0 taken 151368 times.
✓ Branch 1 taken 34744 times.
186112 if(version > 15) // February 2009
15874 {
15875
1/2
✓ Branch 0 taken 151368 times.
✗ Branch 1 not taken.
151368 if(!p_igetw(&(temp_mapscr->color),f,true))
15876 {
15877 return qe_invalid;
15878 }
15879 151368 }
15880 else
15881 {
15882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34744 times.
34744 if(!p_getc(& tempbyte,f,true))
15883 {
15884 return qe_invalid;
15885 }
15886
15887 34744 temp_mapscr->color = (word) tempbyte;
15888 }
15889
15890
1/2
✓ Branch 0 taken 186112 times.
✗ Branch 1 not taken.
186112 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
15891 {
15892 return qe_invalid;
15893 }
15894
15895
2/2
✓ Branch 0 taken 744448 times.
✓ Branch 1 taken 186112 times.
930560 for(int32_t k=0; k<4; k++)
15896 {
15897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 744448 times.
744448 if(!p_getc(&(temp_mapscr->door[k]),f,true))
15898 {
15899 return qe_invalid;
15900
15901 }
15902 744448 }
15903
15904
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 151368 times.
186112 if(version <= 11)
15905 {
15906
1/2
✓ Branch 0 taken 34744 times.
✗ Branch 1 not taken.
34744 if(!p_getc(&(tempbyte),f,true))
15907 {
15908 return qe_invalid;
15909 }
15910
15911 34744 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15912
15913
2/6
✓ Branch 0 taken 34744 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
34744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15914 {
15915 for(int32_t i=1; i<4; i++)
15916 {
15917 if(!p_getc(&(tempbyte),f,true))
15918 {
15919 return qe_invalid;
15920 }
15921
15922 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15923 }
15924 }
15925 else
15926 {
15927 34744 temp_mapscr->tilewarpdmap[1]=0;
15928 34744 temp_mapscr->tilewarpdmap[2]=0;
15929 34744 temp_mapscr->tilewarpdmap[3]=0;
15930 }
15931 34744 }
15932 else
15933 {
15934
2/2
✓ Branch 0 taken 605472 times.
✓ Branch 1 taken 151368 times.
756840 for(int32_t i=0; i<4; i++)
15935 {
15936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 605472 times.
605472 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
15937 {
15938 return qe_invalid;
15939 }
15940 605472 }
15941 }
15942
15943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 186112 times.
186112 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f,true))
15944 {
15945 return qe_invalid;
15946 }
15947
15948
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 151368 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15949 {
15950
2/2
✓ Branch 0 taken 454104 times.
✓ Branch 1 taken 151368 times.
605472 for(int32_t i=1; i<4; i++)
15951 {
15952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454104 times.
454104 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
15953 {
15954 return qe_invalid;
15955 }
15956 454104 }
15957 151368 }
15958 else
15959 {
15960 34744 temp_mapscr->tilewarpscr[1]=0;
15961 34744 temp_mapscr->tilewarpscr[2]=0;
15962 34744 temp_mapscr->tilewarpscr[3]=0;
15963 }
15964
15965
2/2
✓ Branch 0 taken 151368 times.
✓ Branch 1 taken 34744 times.
186112 if(version >= 15)
15966 {
15967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151368 times.
151368 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
15968 {
15969 return qe_invalid;
15970 }
15971 151368 }
15972 else
15973 {
15974 34744 temp_mapscr->tilewarpoverlayflags=0;
15975 }
15976
15977
1/2
✓ Branch 0 taken 186112 times.
✗ Branch 1 not taken.
186112 if(!p_getc(&(temp_mapscr->exitdir),f,true))
15978 {
15979 return qe_invalid;
15980 }
15981
15982
2/2
✓ Branch 0 taken 179248 times.
✓ Branch 1 taken 6864 times.
186112 if(Header->zelda_version < 0x193)
15983 {
15984
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f,true))
15985 {
15986 return qe_invalid;
15987 }
15988
15989 6864 }
15990
15991
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 186112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15992 {
15993 if(!p_getc(&padding,f,true))
15994 {
15995 return qe_invalid;
15996 }
15997 }
15998
15999
2/2
✓ Branch 0 taken 1861120 times.
✓ Branch 1 taken 186112 times.
2047232 for(int32_t k=0; k<10; k++)
16000 {
16001 /*
16002 if (!temp_mapscr->enemy[k])
16003 {
16004 continue;
16005 }
16006 */
16007
3/6
✓ Branch 0 taken 1792480 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1792480 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1861120 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
16008 {
16009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68640 times.
68640 if(!p_getc(&tempbyte,f,true))
16010 {
16011 return qe_invalid;
16012 }
16013
16014 68640 temp_mapscr->enemy[k]=tempbyte;
16015 68640 }
16016 else
16017 {
16018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1792480 times.
1792480 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
16019 {
16020 return qe_invalid;
16021 }
16022 }
16023
16024
3/6
✓ Branch 0 taken 1792480 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1792480 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1861120 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
16025 {
16026 //using enumerations here is dangerous
16027 //very easy to break old quests -DD
16028
2/2
✓ Branch 0 taken 788 times.
✓ Branch 1 taken 67852 times.
68640 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
16029 {
16030 788 temp_mapscr->enemy[k]+=5;
16031 788 }
16032
2/2
✓ Branch 0 taken 67812 times.
✓ Branch 1 taken 40 times.
67852 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
16033 {
16034 40 temp_mapscr->enemy[k]+=1;
16035 40 }
16036 68640 }
16037
16038
2/2
✓ Branch 0 taken 1513680 times.
✓ Branch 1 taken 347440 times.
1861120 if(version < 9)
16039 {
16040
2/2
✓ Branch 0 taken 318415 times.
✓ Branch 1 taken 29025 times.
347440 if(temp_mapscr->enemy[k]>0)
16041 {
16042 29025 temp_mapscr->enemy[k]+=10;
16043 29025 }
16044 347440 }
16045 //don't read in any invalid data
16046
2/2
✓ Branch 0 taken 1861100 times.
✓ Branch 1 taken 20 times.
1861120 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
16047 {
16048 20 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
16049 20 temp_mapscr->enemy[k] = 0;
16050 20 }
16051 1861120 }
16052
16053
1/2
✓ Branch 0 taken 186112 times.
✗ Branch 1 not taken.
186112 if(!p_getc(&(temp_mapscr->pattern),f,true))
16054 {
16055 return qe_invalid;
16056 }
16057
16058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 186112 times.
186112 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f,true))
16059 {
16060 return qe_invalid;
16061 }
16062
16063
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 151368 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16064 {
16065
2/2
✓ Branch 0 taken 454104 times.
✓ Branch 1 taken 151368 times.
605472 for(int32_t i=1; i<4; i++)
16066 {
16067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454104 times.
454104 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
16068 {
16069 return qe_invalid;
16070 }
16071 454104 }
16072 151368 }
16073 else
16074 {
16075 34744 temp_mapscr->sidewarptype[1]=0;
16076 34744 temp_mapscr->sidewarptype[2]=0;
16077 34744 temp_mapscr->sidewarptype[3]=0;
16078 }
16079
16080
2/2
✓ Branch 0 taken 151368 times.
✓ Branch 1 taken 34744 times.
186112 if(version >= 15)
16081 {
16082
1/2
✓ Branch 0 taken 151368 times.
✗ Branch 1 not taken.
151368 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
16083 {
16084 return qe_invalid;
16085 }
16086 151368 }
16087 else
16088 {
16089 34744 temp_mapscr->sidewarpoverlayflags=0;
16090 }
16091
16092
1/2
✓ Branch 0 taken 186112 times.
✗ Branch 1 not taken.
186112 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
16093 {
16094 return qe_invalid;
16095 }
16096
16097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 186112 times.
186112 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
16098 {
16099 return qe_invalid;
16100 }
16101
16102
2/2
✓ Branch 0 taken 744448 times.
✓ Branch 1 taken 186112 times.
930560 for(int32_t k=0; k<4; k++)
16103 {
16104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 744448 times.
744448 if(!p_getc(&(temp_mapscr->path[k]),f,true))
16105 {
16106 return qe_invalid;
16107 }
16108 744448 }
16109
16110
1/2
✓ Branch 0 taken 186112 times.
✗ Branch 1 not taken.
186112 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f,true))
16111 {
16112 return qe_invalid;
16113 }
16114
16115
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 151368 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16116 {
16117
2/2
✓ Branch 0 taken 151368 times.
✓ Branch 1 taken 454104 times.
605472 for(int32_t i=1; i<4; i++)
16118 {
16119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454104 times.
454104 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
16120 {
16121 return qe_invalid;
16122 }
16123 454104 }
16124 151368 }
16125 else
16126 {
16127 34744 temp_mapscr->sidewarpscr[1]=0;
16128 34744 temp_mapscr->sidewarpscr[2]=0;
16129 34744 temp_mapscr->sidewarpscr[3]=0;
16130 }
16131
16132
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 151368 times.
186112 if(version <= 11)
16133 {
16134
1/2
✓ Branch 0 taken 34744 times.
✗ Branch 1 not taken.
34744 if(!p_getc(&(tempbyte),f,true))
16135 {
16136 return qe_invalid;
16137 }
16138
16139 34744 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
16140
16141
2/6
✓ Branch 0 taken 34744 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
34744 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16142 {
16143 for(int32_t i=1; i<4; i++)
16144 {
16145 if(!p_getc(&(tempbyte),f,true))
16146 {
16147 return qe_invalid;
16148 }
16149
16150 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
16151 }
16152 }
16153 else
16154 {
16155 34744 temp_mapscr->sidewarpdmap[1]=0;
16156 34744 temp_mapscr->sidewarpdmap[2]=0;
16157 34744 temp_mapscr->sidewarpdmap[3]=0;
16158 }
16159 34744 }
16160 else
16161 {
16162
2/2
✓ Branch 0 taken 605472 times.
✓ Branch 1 taken 151368 times.
756840 for(int32_t i=0; i<4; i++)
16163 {
16164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 605472 times.
605472 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
16165 {
16166 return qe_invalid;
16167 }
16168 605472 }
16169 }
16170
16171
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 151368 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16172 {
16173
1/2
✓ Branch 0 taken 151368 times.
✗ Branch 1 not taken.
151368 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
16174 {
16175 return qe_invalid;
16176 }
16177 151368 }
16178 34744 else temp_mapscr->sidewarpindex = 0;
16179
16180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 186112 times.
186112 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
16181 {
16182 return qe_invalid;
16183 }
16184
16185
2/2
✓ Branch 0 taken 179248 times.
✓ Branch 1 taken 6864 times.
186112 if(Header->zelda_version < 0x193)
16186 {
16187
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&(temp_mapscr->old_cpage),f,true))
16188 {
16189 return qe_invalid;
16190 }
16191 6864 }
16192
16193
1/2
✓ Branch 0 taken 186112 times.
✗ Branch 1 not taken.
186112 if(!p_getc(&(temp_mapscr->undercset),f,true)) //recalculated for older quests
16194 {
16195 return qe_invalid;
16196 }
16197
16198
1/2
✓ Branch 0 taken 186112 times.
✗ Branch 1 not taken.
186112 if(!p_igetw(&(temp_mapscr->catchall),f,true))
16199 {
16200 return qe_invalid;
16201 }
16202
16203
1/2
✓ Branch 0 taken 186112 times.
✗ Branch 1 not taken.
186112 if(!p_getc(&(temp_mapscr->flags),f,true))
16204 {
16205 return qe_invalid;
16206 }
16207
16208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 186112 times.
186112 if(!p_getc(&(temp_mapscr->flags2),f,true))
16209 {
16210 return qe_invalid;
16211 }
16212
16213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 186112 times.
186112 if(!p_getc(&(temp_mapscr->flags3),f,true))
16214 {
16215 return qe_invalid;
16216 }
16217
16218
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 151368 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16219 //if (version>2)
16220 {
16221
1/2
✓ Branch 0 taken 151368 times.
✗ Branch 1 not taken.
151368 if(!p_getc(&(temp_mapscr->flags4),f,true))
16222 {
16223 return qe_invalid;
16224 }
16225 151368 }
16226
16227
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 151368 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16228 {
16229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151368 times.
151368 if(!p_getc(&(temp_mapscr->flags5),f,true))
16230 {
16231 return qe_invalid;
16232 }
16233
16234
1/2
✓ Branch 0 taken 151368 times.
✗ Branch 1 not taken.
151368 if(!p_igetw(&(temp_mapscr->noreset),f,true))
16235 {
16236 return qe_invalid;
16237 }
16238
16239
1/2
✓ Branch 0 taken 151368 times.
✗ Branch 1 not taken.
151368 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
16240 {
16241 return qe_invalid;
16242 }
16243
16244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151368 times.
151368 if(temp_mapscr->flags5&32)
16245 {
16246 temp_mapscr->flags5 &= ~32;
16247 temp_mapscr->noreset |= 48;
16248 }
16249
16250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151368 times.
151368 if(version<8)
16251 {
16252 if(temp_mapscr->noreset&1)
16253 {
16254 temp_mapscr->noreset|=8192;
16255 }
16256
16257 if(temp_mapscr->nocarry&1)
16258 {
16259 temp_mapscr->nocarry|=8192;
16260 temp_mapscr->nocarry&=~1;
16261 }
16262 }
16263 151368 }
16264 else
16265 {
16266 34744 temp_mapscr->flags5 = 0;
16267 34744 temp_mapscr->noreset = 0;
16268 34744 temp_mapscr->nocarry = 0;
16269 }
16270
16271
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 151368 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16272 {
16273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151368 times.
151368 if(!p_getc(&(temp_mapscr->flags6),f,true))
16274 {
16275 return qe_invalid;
16276 }
16277 151368 }
16278
16279
2/2
✓ Branch 0 taken 151368 times.
✓ Branch 1 taken 34744 times.
186112 if(version>5)
16280 {
16281
1/2
✓ Branch 0 taken 151368 times.
✗ Branch 1 not taken.
151368 if(!p_getc(&(temp_mapscr->flags7),f,true))
16282 {
16283 return qe_invalid;
16284 }
16285
16286
1/2
✓ Branch 0 taken 151368 times.
✗ Branch 1 not taken.
151368 if(!p_getc(&(temp_mapscr->flags8),f,true))
16287 {
16288 return qe_invalid;
16289 }
16290
16291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151368 times.
151368 if(!p_getc(&(temp_mapscr->flags9),f,true))
16292 {
16293 return qe_invalid;
16294 }
16295
16296
1/2
✓ Branch 0 taken 151368 times.
✗ Branch 1 not taken.
151368 if(!p_getc(&(temp_mapscr->flags10),f,true))
16297 {
16298 return qe_invalid;
16299 }
16300
16301
1/2
✓ Branch 0 taken 151368 times.
✗ Branch 1 not taken.
151368 if(!p_getc(&(temp_mapscr->csensitive),f,true))
16302 {
16303 return qe_invalid;
16304 }
16305 151368 }
16306 else
16307 {
16308 34744 temp_mapscr->csensitive=1;
16309 }
16310
16311
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 151368 times.
186112 if(version<14) // August 2007: screen SFX added
16312 {
16313
2/2
✓ Branch 0 taken 34644 times.
✓ Branch 1 taken 100 times.
34744 if(temp_mapscr->flags&8) //fROAR
16314 {
16315 100 temp_mapscr->bosssfx=
16316
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 91 times.
100 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16317 91 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16318 WAV_ROAR;
16319 100 }
16320
16321
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 34653 times.
34744 if(temp_mapscr->flags&128) //fSEA
16322 {
16323 91 temp_mapscr->oceansfx=WAV_SEA;
16324 91 }
16325
16326 34744 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16327 ? 0 : WAV_SECRET;
16328
16329 34744 temp_mapscr->flags3 &= ~66; //64|2
16330 34744 temp_mapscr->flags2 &= ~32;
16331 34744 temp_mapscr->flags &= ~136; // 128|8
16332 34744 }
16333 else
16334 {
16335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151368 times.
151368 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
16336 {
16337 return qe_invalid;
16338 }
16339
16340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151368 times.
151368 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
16341 {
16342 return qe_invalid;
16343 }
16344
16345
1/2
✓ Branch 0 taken 151368 times.
✗ Branch 1 not taken.
151368 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
16346 {
16347 return qe_invalid;
16348 }
16349 }
16350
16351
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 151368 times.
186112 if(version<15) // October 2007: another SFX
16352 {
16353 34744 temp_mapscr->holdupsfx=WAV_PICKUP;
16354 34744 }
16355 else
16356 {
16357
1/2
✓ Branch 0 taken 151368 times.
✗ Branch 1 not taken.
151368 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
16358 {
16359 return qe_invalid;
16360 }
16361 }
16362
16363
16364
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 179248 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16365 {
16366
2/2
✓ Branch 0 taken 1075488 times.
✓ Branch 1 taken 179248 times.
1254736 for(int32_t k=0; k<6; k++)
16367 {
16368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1075488 times.
1075488 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
16369 {
16370 return qe_invalid;
16371 }
16372 1075488 }
16373
16374
2/2
✓ Branch 0 taken 179248 times.
✓ Branch 1 taken 1075488 times.
1254736 for(int32_t k=0; k<6; k++)
16375 {
16376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1075488 times.
1075488 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
16377 {
16378 return qe_invalid;
16379 }
16380 1075488 }
16381 179248 }
16382
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6864 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16383 {
16384 if(!p_getc(&(temp_mapscr->layermap[2]),f,true))
16385 {
16386 return qe_invalid;
16387 }
16388
16389 if(!p_getc(&(temp_mapscr->layerscreen[2]),f,true))
16390 {
16391 return qe_invalid;
16392 }
16393
16394 if(!p_getc(&(temp_mapscr->layermap[4]),f,true))
16395 {
16396 return qe_invalid;
16397 }
16398
16399 if(!p_getc(&(temp_mapscr->layerscreen[4]),f,true))
16400
16401 {
16402 return qe_invalid;
16403 }
16404 }
16405
16406
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 186112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
186112 if((Header->zelda_version == 0x192)&&(Header->build>149))
16407 {
16408 for(int32_t k=0; k<6; k++)
16409 {
16410 if(!p_getc(&tempbyte,f,true)) //layerxsize
16411 {
16412 return qe_invalid;
16413 }
16414 }
16415
16416 for(int32_t k=0; k<6; k++)
16417 {
16418 if(!p_getc(&tempbyte,f,true)) //layerxspeed
16419 {
16420 return qe_invalid;
16421 }
16422 }
16423
16424 for(int32_t k=0; k<6; k++)
16425 {
16426 if(!p_getc(&tempbyte,f,true)) //layerxdelay
16427 {
16428 return qe_invalid;
16429 }
16430 }
16431
16432 for(int32_t k=0; k<6; k++)
16433 {
16434 if(!p_getc(&tempbyte,f,true)) //layerysize
16435 {
16436 return qe_invalid;
16437 }
16438 }
16439
16440 for(int32_t k=0; k<6; k++)
16441 {
16442 if(!p_getc(&tempbyte,f,true)) //layeryspeed
16443 {
16444 return qe_invalid;
16445 }
16446 }
16447
16448 for(int32_t k=0; k<6; k++)
16449 {
16450 if(!p_getc(&tempbyte,f,true)) //layerydelay
16451 {
16452 return qe_invalid;
16453 }
16454 }
16455 }
16456
16457
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 179248 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16458 {
16459
2/2
✓ Branch 0 taken 1075488 times.
✓ Branch 1 taken 179248 times.
1254736 for(int32_t k=0; k<6; k++)
16460 {
16461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1075488 times.
1075488 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
16462 {
16463 return qe_invalid;
16464 }
16465 1075488 }
16466 179248 }
16467
16468
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 179248 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16469 {
16470
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 179248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
179248 if((Header->zelda_version == 0x192)&&(Header->build>153))
16471 {
16472 if(!p_getc(&padding,f,true))
16473 {
16474 return qe_invalid;
16475 }
16476 }
16477
16478
1/2
✓ Branch 0 taken 179248 times.
✗ Branch 1 not taken.
179248 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
16479 {
16480 return qe_invalid;
16481 }
16482 179248 }
16483
16484
3/6
✓ Branch 0 taken 179248 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 179248 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16485 {
16486 6864 extras=15;
16487 6864 }
16488
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 179248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
179248 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16489 {
16490 extras=11;
16491 }
16492
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 179248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
179248 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16493 {
16494 extras=32;
16495 }
16496
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 179248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
179248 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16497 {
16498 extras=64;
16499 }
16500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 179248 times.
179248 else if(Header->zelda_version < 0x193)
16501 {
16502 extras=62;
16503 }
16504 else
16505
16506 {
16507 179248 extras=0;
16508 }
16509
16510
2/2
✓ Branch 0 taken 102960 times.
✓ Branch 1 taken 186112 times.
289072 for(int32_t k=0; k<extras; k++)
16511 {
16512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102960 times.
102960 if(!p_getc(&tempbyte,f,true)) //extra[k]
16513 {
16514 return qe_invalid;
16515 }
16516 102960 }
16517
16518
3/6
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 151368 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34744 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16519 //if (version>3)
16520 {
16521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151368 times.
151368 if(!p_getc(&(temp_mapscr->nextmap),f,true))
16522 {
16523 return qe_invalid;
16524 }
16525
16526
1/2
✓ Branch 0 taken 151368 times.
✗ Branch 1 not taken.
151368 if(!p_getc(&(temp_mapscr->nextscr),f,true))
16527 {
16528 return qe_invalid;
16529 }
16530 151368 }
16531 else
16532 {
16533 34744 temp_mapscr->nextmap=0;
16534 34744 temp_mapscr->nextscr=0;
16535 }
16536
16537
3/6
✓ Branch 0 taken 179248 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 179248 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16538 {
16539 6864 secretcombos=20;
16540 6864 }
16541
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 179248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
179248 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16542 {
16543 secretcombos=256;
16544 }
16545 else
16546 {
16547 179248 secretcombos=128;
16548 }
16549
16550
3/6
✓ Branch 0 taken 179248 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 179248 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16551 {
16552
2/2
✓ Branch 0 taken 137280 times.
✓ Branch 1 taken 6864 times.
144144 for(int32_t k=0; k<secretcombos; k++)
16553 {
16554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(!p_getc(&tempbyte,f,true))
16555 {
16556 return qe_invalid;
16557 }
16558
16559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(k<128)
16560 {
16561 137280 temp_mapscr->secretcombo[k]=tempbyte;
16562 137280 }
16563 137280 }
16564 6864 }
16565 else
16566 {
16567
2/2
✓ Branch 0 taken 22943744 times.
✓ Branch 1 taken 179248 times.
23122992 for(int32_t k=0; k<128; k++)
16568 {
16569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22943744 times.
22943744 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
16570 {
16571 return qe_invalid;
16572 }
16573
16574 22943744 }
16575 }
16576
16577
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 179248 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16578 {
16579
2/2
✓ Branch 0 taken 22943744 times.
✓ Branch 1 taken 179248 times.
23122992 for(int32_t k=0; k<128; k++)
16580 {
16581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22943744 times.
22943744 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
16582 {
16583 return qe_invalid;
16584 }
16585 22943744 }
16586
16587
2/2
✓ Branch 0 taken 22943744 times.
✓ Branch 1 taken 179248 times.
23122992 for(int32_t k=0; k<128; k++)
16588 {
16589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22943744 times.
22943744 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
16590 {
16591 return qe_invalid;
16592 }
16593 22943744 }
16594 179248 }
16595
16596
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 186112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16597 {
16598 if(!p_getc(&padding,f,true))
16599 {
16600 return qe_invalid;
16601 }
16602 }
16603
16604 186112 const int32_t _mapsSize = (temp_map->tileWidth*temp_map->tileHeight);
16605
16606
2/2
✓ Branch 0 taken 32755712 times.
✓ Branch 1 taken 186112 times.
32941824 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16607 {
16608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32755712 times.
32755712 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
16609 {
16610 return qe_invalid;
16611 }
16612 32755712 }
16613
16614
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 186112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16615 {
16616 if(!p_getc(&padding,f,true))
16617 {
16618 return qe_invalid;
16619 }
16620
16621 if(!p_getc(&padding,f,true))
16622 {
16623 return qe_invalid;
16624 }
16625 }
16626
16627
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 179248 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16628 {
16629
2/2
✓ Branch 0 taken 31547648 times.
✓ Branch 1 taken 179248 times.
31726896 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16630 {
16631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31547648 times.
31547648 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
16632 {
16633 return qe_invalid;
16634 }
16635
16636
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31547648 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31547648 if((Header->zelda_version == 0x192)&&(Header->build<24))
16637 {
16638 if(!p_getc(&tempbyte,f,true))
16639 {
16640 return qe_invalid;
16641 }
16642
16643 if(!p_getc(&tempbyte,f,true))
16644 {
16645 return qe_invalid;
16646 }
16647
16648 if(!p_getc(&tempbyte,f,true))
16649 {
16650 return qe_invalid;
16651 }
16652 }
16653 31547648 }
16654 179248 }
16655
16656
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 179248 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16657 {
16658
2/2
✓ Branch 0 taken 179248 times.
✓ Branch 1 taken 31547648 times.
31726896 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16659 {
16660
16661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31547648 times.
31547648 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
16662 {
16663 return qe_invalid;
16664 }
16665 31547648 }
16666 179248 }
16667
16668
3/6
✓ Branch 0 taken 179248 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 179248 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16669 {
16670 6864 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16671 6864 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16672 6864 }
16673
16674
3/6
✓ Branch 0 taken 179248 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 179248 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16675 {
16676 6864 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16677 6864 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16678 6864 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16679 6864 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16680 6864 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16681 6864 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16682 6864 }
16683
16684
3/6
✓ Branch 0 taken 179248 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 179248 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
186112 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16685 {
16686
2/2
✓ Branch 0 taken 1208064 times.
✓ Branch 1 taken 6864 times.
1214928 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16687 {
16688
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version == 0x192)&&(Header->build>149))
16689 {
16690 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16691 {
16692 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16693 }
16694 }
16695 else
16696 {
16697
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version < 0x192)||
16698 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16699 {
16700 1208064 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16701 1208064 }
16702
16703 1208064 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16704 }
16705
16706 1208064 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16707 1208064 }
16708 6864 }
16709
16710 /*if(version>12)
16711 {
16712 if(!p_getc(&(temp_mapscr->scrWidth),f,true))
16713 {
16714 return qe_invalid;
16715 }
16716 if(!p_getc(&(temp_mapscr->scrHeight),f,true))
16717 {
16718 return qe_invalid;
16719 }
16720 }*/
16721
16722
2/2
✓ Branch 0 taken 151368 times.
✓ Branch 1 taken 34744 times.
186112 if(version>4)
16723 {
16724
1/2
✓ Branch 0 taken 151368 times.
✗ Branch 1 not taken.
151368 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
16725 {
16726 return qe_invalid;
16727 }
16728 151368 }
16729 else
16730 {
16731 34744 temp_mapscr->screen_midi = -1;
16732 }
16733
16734
2/2
✓ Branch 0 taken 151368 times.
✓ Branch 1 taken 34744 times.
186112 if(version>=17)
16735 {
16736
1/2
✓ Branch 0 taken 151368 times.
✗ Branch 1 not taken.
151368 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
16737 {
16738 return qe_invalid;
16739 }
16740 151368 }
16741 else
16742 {
16743 34744 temp_mapscr->lens_layer = llNORMAL;
16744 }
16745
16746
2/2
✓ Branch 0 taken 34744 times.
✓ Branch 1 taken 151368 times.
186112 if(version>6)
16747 {
16748 dword bits;
16749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151368 times.
151368 if(!p_igetl(&bits,f,true))
16750 {
16751 return qe_invalid;
16752 }
16753
16754 int32_t m;
16755 float tempfloat;
16756 word tempw;
16757 151368 temp_mapscr->ffcCountMarkDirty();
16758
16759
2/2
✓ Branch 0 taken 151368 times.
✓ Branch 1 taken 4843776 times.
4995144 for(m=0; m<32; m++)
16760 {
16761 4843776 ffcdata& tempffc = temp_mapscr->ffcs[m];
16762 4843776 tempffc.clear();
16763
2/2
✓ Branch 0 taken 4821432 times.
✓ Branch 1 taken 22344 times.
4843776 if((bits>>m)&1)
16764 {
16765
1/2
✓ Branch 0 taken 22344 times.
✗ Branch 1 not taken.
22344 if(!p_igetw(&tempw,f,true))
16766 {
16767 return qe_invalid;
16768 }
16769 22344 tempffc.setData(tempw);
16770
16771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22344 times.
22344 if(!p_getc(&(tempffc.cset),f,true))
16772 {
16773 return qe_invalid;
16774 }
16775
16776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22344 times.
22344 if(!p_igetw(&(tempffc.delay),f,true))
16777 {
16778 return qe_invalid;
16779 }
16780
16781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22344 times.
22344 if(version < 9)
16782 {
16783 if(!p_igetf(&tempfloat,f,true))
16784 {
16785 return qe_invalid;
16786 }
16787
16788 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16789
16790 if(!p_igetf(&tempfloat,f,true))
16791 {
16792 return qe_invalid;
16793 }
16794
16795 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16796
16797 if(!p_igetf(&tempfloat,f,true))
16798 {
16799 return qe_invalid;
16800 }
16801
16802 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16803
16804 if(!p_igetf(&tempfloat,f,true))
16805 {
16806 return qe_invalid;
16807 }
16808
16809 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16810
16811 if(!p_igetf(&tempfloat,f,true))
16812 {
16813 return qe_invalid;
16814 }
16815
16816 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16817
16818 if(!p_igetf(&tempfloat,f,true))
16819 {
16820 return qe_invalid;
16821 }
16822
16823 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16824 }
16825 else
16826 {
16827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22344 times.
22344 if(!p_igetzf(&(tempffc.x),f,true))
16828 {
16829 return qe_invalid;
16830 }
16831
16832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22344 times.
22344 if(!p_igetzf(&(tempffc.y),f,true))
16833 {
16834 return qe_invalid;
16835 }
16836
16837
1/2
✓ Branch 0 taken 22344 times.
✗ Branch 1 not taken.
22344 if(!p_igetzf(&(tempffc.vx),f,true))
16838 {
16839 return qe_invalid;
16840 }
16841
16842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22344 times.
22344 if(!p_igetzf(&(tempffc.vy),f,true))
16843 {
16844 return qe_invalid;
16845 }
16846
16847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22344 times.
22344 if(!p_igetzf(&(tempffc.ax),f,true))
16848 {
16849 return qe_invalid;
16850 }
16851
16852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22344 times.
22344 if(!p_igetzf(&(tempffc.ay),f,true))
16853 {
16854 return qe_invalid;
16855 }
16856 }
16857
16858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22344 times.
22344 if(!p_getc(&(tempffc.link),f,true))
16859 {
16860 return qe_invalid;
16861 }
16862
16863
1/2
✓ Branch 0 taken 22344 times.
✗ Branch 1 not taken.
22344 if(version>7)
16864 {
16865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22344 times.
22344 if(!p_getc(&tempbyte,f,true))
16866 {
16867 return qe_invalid;
16868 }
16869
16870 22344 tempffc.hxsz = (tempbyte&0x3F)+1;
16871 22344 tempffc.txsz = (tempbyte>>6)+1;
16872
16873
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22344 times.
22344 if(!p_getc(&tempbyte,f,true))
16874 {
16875 return qe_invalid;
16876 }
16877
16878 22344 tempffc.hysz = (tempbyte&0x3F)+1;
16879 22344 tempffc.tysz = (tempbyte>>6)+1;
16880
16881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22344 times.
22344 if(!p_igetl(&(tempffc.flags),f,true))
16882 {
16883 return qe_invalid;
16884 }
16885 22344 }
16886 else
16887 {
16888 tempffc.hxsz=16;
16889 tempffc.hysz=16;
16890 tempffc.txsz=1;
16891 tempffc.tysz=1;
16892 tempffc.flags=0;
16893 }
16894
16895 22344 tempffc.updateSolid();
16896
16897
16898
4/6
✓ Branch 0 taken 22344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20324 times.
✓ Branch 3 taken 2020 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 20324 times.
22344 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16899 {
16900 tempffc.flags|=ffIGNOREHOLDUP;
16901 }
16902
16903
1/2
✓ Branch 0 taken 22344 times.
✗ Branch 1 not taken.
22344 if(version>9)
16904 {
16905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22344 times.
22344 if(!p_igetw(&(tempffc.script),f,true))
16906 {
16907 return qe_invalid;
16908 }
16909 22344 }
16910 else
16911 {
16912 tempffc.script=0;
16913 }
16914
16915
1/2
✓ Branch 0 taken 22344 times.
✗ Branch 1 not taken.
22344 if(version>10)
16916 {
16917
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22344 times.
22344 if(!p_igetl(&(tempffc.initd[0]),f,true))
16918 {
16919 return qe_invalid;
16920 }
16921
16922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22344 times.
22344 if(!p_igetl(&(tempffc.initd[1]),f,true))
16923 {
16924 return qe_invalid;
16925 }
16926
16927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22344 times.
22344 if(!p_igetl(&(tempffc.initd[2]),f,true))
16928 {
16929 return qe_invalid;
16930 }
16931
16932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22344 times.
22344 if(!p_igetl(&(tempffc.initd[3]),f,true))
16933 {
16934 return qe_invalid;
16935 }
16936
16937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22344 times.
22344 if(!p_igetl(&(tempffc.initd[4]),f,true))
16938 {
16939 return qe_invalid;
16940 }
16941
16942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22344 times.
22344 if(!p_igetl(&(tempffc.initd[5]),f,true))
16943 {
16944 return qe_invalid;
16945 }
16946
16947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22344 times.
22344 if(!p_igetl(&(tempffc.initd[6]),f,true))
16948 {
16949 return qe_invalid;
16950 }
16951
16952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22344 times.
22344 if(!p_igetl(&(tempffc.initd[7]),f,true))
16953 {
16954 return qe_invalid;
16955 }
16956
16957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22344 times.
22344 if(!p_getc(&(tempbyte),f,true))
16958 {
16959 return qe_invalid;
16960 }
16961
16962 22344 tempffc.inita[0]=tempbyte*10000;
16963
16964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22344 times.
22344 if(!p_getc(&(tempbyte),f,true))
16965 {
16966 return qe_invalid;
16967 }
16968
16969 22344 tempffc.inita[1]=tempbyte*10000;
16970 22344 }
16971 else
16972 {
16973 tempffc.inita[0] = 10000;
16974 tempffc.inita[1] = 10000;
16975 }
16976
16977 22344 tempffc.initialized = false;
16978
16979
1/2
✓ Branch 0 taken 22344 times.
✗ Branch 1 not taken.
22344 if(version <= 11)
16980 {
16981 fixffcs=true;
16982 }
16983 22344 }
16984 4843776 }
16985
16986 151368 }
16987
16988 //add in the new whistle flags
16989
2/2
✓ Branch 0 taken 151368 times.
✓ Branch 1 taken 34744 times.
186112 if(version<13)
16990 {
16991
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 34732 times.
34744 if(temp_mapscr->flags & fWHISTLE)
16992 {
16993 12 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16994 12 }
16995 34744 }
16996
16997 // for(int32_t m=0; m<32; m++)
16998 // {
16999 // // ffcScriptData used to be part of mapscr, and this was handled just above
17000 // ffcScriptData[m].a[0] = 10000;
17001 // ffcScriptData[m].a[1] = 10000;
17002 // }
17003
17004 //2.55 starts here
17005
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 172376 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
186112 if ( version >= 19 && Header->zelda_version > 0x253 )
17006 {
17007
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
17008 {
17009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
17010 {
17011 return qe_invalid;
17012 }
17013 137360 }
17014
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
17015 {
17016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
17017 {
17018 return qe_invalid;
17019 }
17020 137360 }
17021
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
17022 {
17023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
17024 {
17025 return qe_invalid;
17026 }
17027 137360 }
17028
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 137360 times.
151096 for ( int32_t q = 0; q < 10; q++ )
17029 {
17030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
17031 {
17032 return qe_invalid;
17033 }
17034 137360 }
17035 13736 }
17036
3/4
✓ Branch 0 taken 172376 times.
✓ Branch 1 taken 13736 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 172376 times.
186112 if ( version < 19 && Header->zelda_version > 0x253 )
17037 {
17038 for ( int32_t q = 0; q < 10; q++ )
17039 {
17040 temp_mapscr->npcstrings[q] = 0;
17041 temp_mapscr->new_items[q] = 0;
17042 temp_mapscr->new_item_x[q] = 0;
17043 temp_mapscr->new_item_y[q] = 0;
17044 }
17045 }
17046
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 172376 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
186112 if ( version >= 20 && Header->zelda_version > 0x253 )
17047 {
17048
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_igetw(&(temp_mapscr->script),f,true))
17049 {
17050 return qe_invalid;
17051 }
17052
2/2
✓ Branch 0 taken 109888 times.
✓ Branch 1 taken 13736 times.
123624 for ( int32_t q = 0; q < 8; q++)
17053 {
17054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109888 times.
109888 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
17055 {
17056 return qe_invalid;
17057 }
17058 109888 }
17059 13736 }
17060
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 172376 times.
186112 if ( version < 20 )
17061 {
17062 172376 temp_mapscr->script = 0;
17063
2/2
✓ Branch 0 taken 1379008 times.
✓ Branch 1 taken 172376 times.
1551384 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
17064 172376 }
17065
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 172376 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
186112 if ( version >= 21 && Header->zelda_version > 0x253 )
17066 {
17067
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
17068 {
17069 return qe_invalid;
17070 }
17071 13736 }
17072
2/2
✓ Branch 0 taken 172376 times.
✓ Branch 1 taken 13736 times.
186112 if ( version < 21 )
17073 {
17074 172376 temp_mapscr->preloadscript = 0;
17075 172376 }
17076 //all builds with version > 20 need this. -Z
17077 186112 temp_mapscr->ffcswaitdraw = 0;
17078
17079
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 172376 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
186112 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
17080 {
17081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13736 times.
13736 if(!p_getc(&(temp_mapscr->hidelayers ),f,true))
17082 {
17083 return qe_invalid;
17084 }
17085
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f,true))
17086 {
17087 return qe_invalid;
17088 }
17089 13736 }
17090
2/2
✓ Branch 0 taken 172376 times.
✓ Branch 1 taken 13736 times.
186112 if ( version < 22 )
17091 {
17092 172376 temp_mapscr->hidelayers = 0;
17093 172376 temp_mapscr->hidescriptlayers = 0;
17094 172376 }
17095
17096 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
17097 //May be any version before 2.11. -Z
17098 /* --not the roar, the HIT SFX
17099 if ( Header->zelda_version <= 0x210 )
17100 {
17101 if ( temp_mapscr->bosssfx == WAV_DODONGO )
17102 {
17103 temp_mapscr->bosssfx = WAV_ROAR;
17104 }
17105 }
17106 */
17107
17108 186112 return 0;
17109 186112 }
17110 199168 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
17111 {
17112
2/2
✓ Branch 0 taken 186112 times.
✓ Branch 1 taken 13056 times.
199168 if(version < 23)
17113 {
17114 186112 auto ret = readmapscreen_old(f,Header,temp_mapscr,temp_map,version);
17115
1/2
✓ Branch 0 taken 186112 times.
✗ Branch 1 not taken.
186112 if(ret) return ret;
17116 186112 }
17117 else
17118 {
17119
1/2
✓ Branch 0 taken 13056 times.
✗ Branch 1 not taken.
13056 if(!p_getc(&(temp_mapscr->valid),f,true))
17120 return qe_invalid;
17121
2/2
✓ Branch 0 taken 5267 times.
✓ Branch 1 taken 7789 times.
13056 if(!(temp_mapscr->valid & mVALID))
17122 7789 return 0; //Empty screen
17123 uint32_t scr_has_flags;
17124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5267 times.
5267 if(!p_igetl(&scr_has_flags,f,true))
17125 return qe_invalid;
17126
17127
2/2
✓ Branch 0 taken 5222 times.
✓ Branch 1 taken 45 times.
5267 if(scr_has_flags & SCRHAS_ROOMDATA)
17128 {
17129
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!p_getc(&(temp_mapscr->guy),f,true))
17130 return qe_invalid;
17131
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!p_igetw(&(temp_mapscr->str),f,true))
17132 return qe_invalid;
17133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(!p_getc(&(temp_mapscr->room),f,true))
17134 return qe_invalid;
17135
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!p_igetw(&(temp_mapscr->catchall),f,true))
17136 return qe_invalid;
17137 45 }
17138
2/2
✓ Branch 0 taken 5186 times.
✓ Branch 1 taken 81 times.
5267 if(scr_has_flags & SCRHAS_ITEM)
17139 {
17140
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_getc(&(temp_mapscr->item),f,true))
17141 return qe_invalid;
17142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if(!p_getc(&(temp_mapscr->hasitem),f,true))
17143 return qe_invalid;
17144
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_getc(&(temp_mapscr->itemx),f,true))
17145 return qe_invalid;
17146
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_getc(&(temp_mapscr->itemy),f,true))
17147 return qe_invalid;
17148 81 }
17149
2/2
✓ Branch 0 taken 4975 times.
✓ Branch 1 taken 292 times.
5267 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
17150 {
17151
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
17152 return qe_invalid;
17153 292 }
17154
2/2
✓ Branch 0 taken 5069 times.
✓ Branch 1 taken 198 times.
5267 if(scr_has_flags & SCRHAS_TWARP)
17155 {
17156
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
17157 {
17158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
17159 return qe_invalid;
17160 792 }
17161
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
17162 {
17163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
17164 return qe_invalid;
17165 792 }
17166
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
17167 {
17168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
17169 return qe_invalid;
17170 792 }
17171
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
17172 return qe_invalid;
17173 198 }
17174
2/2
✓ Branch 0 taken 5149 times.
✓ Branch 1 taken 118 times.
5267 if(scr_has_flags & SCRHAS_SWARP)
17175 {
17176
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 118 times.
590 for(int32_t i=0; i<4; i++)
17177 {
17178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472 times.
472 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
17179 return qe_invalid;
17180 472 }
17181
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 118 times.
590 for(int32_t i=0; i<4; i++)
17182 {
17183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472 times.
472 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
17184 return qe_invalid;
17185 472 }
17186
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 118 times.
590 for(int32_t i=0; i<4; i++)
17187 {
17188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472 times.
472 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
17189 return qe_invalid;
17190 472 }
17191
1/2
✓ Branch 0 taken 118 times.
✗ Branch 1 not taken.
118 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
17192 return qe_invalid;
17193
1/2
✓ Branch 0 taken 118 times.
✗ Branch 1 not taken.
118 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
17194 return qe_invalid;
17195 118 }
17196
2/2
✓ Branch 0 taken 4971 times.
✓ Branch 1 taken 296 times.
5267 if(scr_has_flags & SCRHAS_WARPRET)
17197 {
17198
2/2
✓ Branch 0 taken 1184 times.
✓ Branch 1 taken 296 times.
1480 for(int32_t i=0; i<4; i++)
17199 {
17200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1184 times.
1184 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
17201 return qe_invalid;
17202 1184 }
17203
2/2
✓ Branch 0 taken 1184 times.
✓ Branch 1 taken 296 times.
1480 for(int32_t i=0; i<4; i++)
17204 {
17205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1184 times.
1184 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
17206 return qe_invalid;
17207 1184 }
17208
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
17209 return qe_invalid;
17210
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
17211 return qe_invalid;
17212 296 }
17213
2/2
✓ Branch 0 taken 1036 times.
✓ Branch 1 taken 4231 times.
5267 if(scr_has_flags & SCRHAS_LAYERS)
17214 {
17215
2/2
✓ Branch 0 taken 6216 times.
✓ Branch 1 taken 1036 times.
7252 for(int32_t k=0; k<6; k++)
17216 {
17217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6216 times.
6216 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
17218 return qe_invalid;
17219 6216 }
17220
2/2
✓ Branch 0 taken 6216 times.
✓ Branch 1 taken 1036 times.
7252 for(int32_t k=0; k<6; k++)
17221 {
17222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6216 times.
6216 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
17223 return qe_invalid;
17224 6216 }
17225
2/2
✓ Branch 0 taken 6216 times.
✓ Branch 1 taken 1036 times.
7252 for(int32_t k=0; k<6; k++)
17226 {
17227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6216 times.
6216 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
17228 return qe_invalid;
17229 6216 }
17230
1/2
✓ Branch 0 taken 1036 times.
✗ Branch 1 not taken.
1036 if(!p_getc(&(temp_mapscr->hidelayers),f,true))
17231 return qe_invalid;
17232
1/2
✓ Branch 0 taken 1036 times.
✗ Branch 1 not taken.
1036 if(!p_getc(&(temp_mapscr->hidescriptlayers),f,true))
17233 return qe_invalid;
17234 1036 }
17235 else
17236 {
17237
2/2
✓ Branch 0 taken 25386 times.
✓ Branch 1 taken 4231 times.
29617 for(int32_t k=0; k<6; k++)
17238 {
17239 25386 temp_mapscr->layeropacity[k] = 255;
17240 25386 }
17241 }
17242
1/2
✓ Branch 0 taken 5267 times.
✗ Branch 1 not taken.
5267 if(scr_has_flags & SCRHAS_MAZE)
17243 {
17244 for(int32_t k=0; k<4; k++)
17245 {
17246 if(!p_getc(&(temp_mapscr->path[k]),f,true))
17247 return qe_invalid;
17248 }
17249 if(!p_getc(&(temp_mapscr->exitdir),f,true))
17250 return qe_invalid;
17251 }
17252
2/2
✓ Branch 0 taken 5159 times.
✓ Branch 1 taken 108 times.
5267 if(scr_has_flags & SCRHAS_D_S_U)
17253 {
17254
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
17255 return qe_invalid;
17256
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 108 times.
540 for(int32_t k=0; k<4; k++)
17257 {
17258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 432 times.
432 if(!p_getc(&(temp_mapscr->door[k]),f,true))
17259 return qe_invalid;
17260 432 }
17261
17262
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!p_getc(&(temp_mapscr->stairx),f,true))
17263 return qe_invalid;
17264
17265
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!p_getc(&(temp_mapscr->stairy),f,true))
17266 return qe_invalid;
17267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
17268 return qe_invalid;
17269
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!p_getc(&(temp_mapscr->undercset),f,true))
17270 return qe_invalid;
17271 108 }
17272
2/2
✓ Branch 0 taken 4904 times.
✓ Branch 1 taken 363 times.
5267 if(scr_has_flags & SCRHAS_FLAGS)
17273 {
17274
1/2
✓ Branch 0 taken 363 times.
✗ Branch 1 not taken.
363 if(!p_getc(&(temp_mapscr->flags),f,true))
17275 return qe_invalid;
17276
1/2
✓ Branch 0 taken 363 times.
✗ Branch 1 not taken.
363 if(!p_getc(&(temp_mapscr->flags2),f,true))
17277 return qe_invalid;
17278
1/2
✓ Branch 0 taken 363 times.
✗ Branch 1 not taken.
363 if(!p_getc(&(temp_mapscr->flags3),f,true))
17279 return qe_invalid;
17280
1/2
✓ Branch 0 taken 363 times.
✗ Branch 1 not taken.
363 if(!p_getc(&(temp_mapscr->flags4),f,true))
17281 return qe_invalid;
17282
1/2
✓ Branch 0 taken 363 times.
✗ Branch 1 not taken.
363 if(!p_getc(&(temp_mapscr->flags5),f,true))
17283 return qe_invalid;
17284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 363 times.
363 if(!p_getc(&(temp_mapscr->flags6),f,true))
17285 return qe_invalid;
17286
1/2
✓ Branch 0 taken 363 times.
✗ Branch 1 not taken.
363 if(!p_getc(&(temp_mapscr->flags7),f,true))
17287 return qe_invalid;
17288
1/2
✓ Branch 0 taken 363 times.
✗ Branch 1 not taken.
363 if(!p_getc(&(temp_mapscr->flags8),f,true))
17289 return qe_invalid;
17290
1/2
✓ Branch 0 taken 363 times.
✗ Branch 1 not taken.
363 if(!p_getc(&(temp_mapscr->flags9),f,true))
17291 return qe_invalid;
17292
1/2
✓ Branch 0 taken 363 times.
✗ Branch 1 not taken.
363 if(!p_getc(&(temp_mapscr->flags10),f,true))
17293 return qe_invalid;
17294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 363 times.
363 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
17295 return qe_invalid;
17296 363 }
17297
2/2
✓ Branch 0 taken 4949 times.
✓ Branch 1 taken 318 times.
5267 if(scr_has_flags & SCRHAS_ENEMY)
17298 {
17299
2/2
✓ Branch 0 taken 3180 times.
✓ Branch 1 taken 318 times.
3498 for(int32_t k=0; k<10; k++)
17300 {
17301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3180 times.
3180 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
17302 return qe_invalid;
17303
1/2
✓ Branch 0 taken 3180 times.
✗ Branch 1 not taken.
3180 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17304 temp_mapscr->enemy[k] = 0;
17305 3180 }
17306
1/2
✓ Branch 0 taken 318 times.
✗ Branch 1 not taken.
318 if(!p_getc(&(temp_mapscr->pattern),f,true))
17307 return qe_invalid;
17308 318 }
17309
2/2
✓ Branch 0 taken 5236 times.
✓ Branch 1 taken 31 times.
5267 if(scr_has_flags & SCRHAS_CARRY)
17310 {
17311
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&(temp_mapscr->noreset),f,true))
17312 return qe_invalid;
17313
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
17314 return qe_invalid;
17315
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_getc(&(temp_mapscr->nextmap),f,true))
17316 return qe_invalid;
17317
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_getc(&(temp_mapscr->nextscr),f,true))
17318 return qe_invalid;
17319 31 }
17320
2/2
✓ Branch 0 taken 5243 times.
✓ Branch 1 taken 24 times.
5267 if(scr_has_flags & SCRHAS_SCRIPT)
17321 {
17322
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&(temp_mapscr->script),f,true))
17323 return qe_invalid;
17324
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
17325 return qe_invalid;
17326
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 24 times.
216 for ( int32_t q = 0; q < 8; q++ )
17327 {
17328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
17329 return qe_invalid;
17330 192 }
17331 24 }
17332
1/2
✓ Branch 0 taken 5267 times.
✗ Branch 1 not taken.
5267 if(scr_has_flags & SCRHAS_UNUSED)
17333 {
17334 for ( int32_t q = 0; q < 10; q++ )
17335 {
17336 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
17337 return qe_invalid;
17338 }
17339 for ( int32_t q = 0; q < 10; q++ )
17340 {
17341 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
17342 return qe_invalid;
17343 }
17344 for ( int32_t q = 0; q < 10; q++ )
17345 {
17346 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
17347 return qe_invalid;
17348 }
17349 for ( int32_t q = 0; q < 10; q++ )
17350 {
17351 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
17352 return qe_invalid;
17353 }
17354 }
17355
2/2
✓ Branch 0 taken 4910 times.
✓ Branch 1 taken 357 times.
5267 if(scr_has_flags & SCRHAS_SECRETS)
17356 {
17357
2/2
✓ Branch 0 taken 45696 times.
✓ Branch 1 taken 357 times.
46053 for(int32_t k=0; k<128; k++)
17358 {
17359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45696 times.
45696 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
17360 return qe_invalid;
17361 45696 }
17362
2/2
✓ Branch 0 taken 45696 times.
✓ Branch 1 taken 357 times.
46053 for(int32_t k=0; k<128; k++)
17363 {
17364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45696 times.
45696 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
17365 return qe_invalid;
17366 45696 }
17367
2/2
✓ Branch 0 taken 45696 times.
✓ Branch 1 taken 357 times.
46053 for(int32_t k=0; k<128; k++)
17368 {
17369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45696 times.
45696 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
17370 return qe_invalid;
17371 45696 }
17372 357 }
17373
2/2
✓ Branch 0 taken 2859 times.
✓ Branch 1 taken 2408 times.
5267 if(scr_has_flags & SCRHAS_COMBOFLAG)
17374 {
17375
2/2
✓ Branch 0 taken 423808 times.
✓ Branch 1 taken 2408 times.
426216 for(int32_t k=0; k<176; ++k)
17376 {
17377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 423808 times.
423808 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
17378 return qe_invalid;
17379 423808 }
17380
2/2
✓ Branch 0 taken 423808 times.
✓ Branch 1 taken 2408 times.
426216 for(int32_t k=0; k<176; ++k)
17381 {
17382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 423808 times.
423808 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
17383 return qe_invalid;
17384 423808 }
17385
2/2
✓ Branch 0 taken 423808 times.
✓ Branch 1 taken 2408 times.
426216 for(int32_t k=0; k<176; ++k)
17386 {
17387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 423808 times.
423808 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
17388 return qe_invalid;
17389 423808 }
17390 2408 }
17391
1/2
✓ Branch 0 taken 5267 times.
✗ Branch 1 not taken.
5267 if(scr_has_flags & SCRHAS_MISC)
17392 {
17393
1/2
✓ Branch 0 taken 5267 times.
✗ Branch 1 not taken.
5267 if(!p_igetw(&(temp_mapscr->color),f,true))
17394 return qe_invalid;
17395
1/2
✓ Branch 0 taken 5267 times.
✗ Branch 1 not taken.
5267 if(!p_getc(&(temp_mapscr->csensitive),f,true))
17396 return qe_invalid;
17397
1/2
✓ Branch 0 taken 5267 times.
✗ Branch 1 not taken.
5267 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
17398 return qe_invalid;
17399
1/2
✓ Branch 0 taken 5267 times.
✗ Branch 1 not taken.
5267 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
17400 return qe_invalid;
17401
1/2
✓ Branch 0 taken 5267 times.
✗ Branch 1 not taken.
5267 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
17402 return qe_invalid;
17403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5267 times.
5267 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
17404 return qe_invalid;
17405
1/2
✓ Branch 0 taken 5267 times.
✗ Branch 1 not taken.
5267 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
17406 return qe_invalid;
17407
1/2
✓ Branch 0 taken 5267 times.
✗ Branch 1 not taken.
5267 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
17408 return qe_invalid;
17409
1/2
✓ Branch 0 taken 5267 times.
✗ Branch 1 not taken.
5267 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
17410 return qe_invalid;
17411 5267 }
17412 else
17413 {
17414 temp_mapscr->screen_midi = -1;
17415 temp_mapscr->csensitive = 1;
17416 }
17417 //FFC
17418 5267 bool old_ff = version < 25;
17419 5267 dword bits = 0;
17420 5267 word numffc = 32;
17421
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 5245 times.
5267 if(old_ff)
17422 {
17423
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(!p_igetl(&bits,f,true))
17424 return qe_invalid;
17425 22 }
17426 else
17427 {
17428
1/2
✓ Branch 0 taken 5245 times.
✗ Branch 1 not taken.
5245 if(!p_igetw(&numffc,f,true))
17429 return qe_invalid;
17430 }
17431 byte tempbyte;
17432 word tempw;
17433
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 5245 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
5267 static ffcdata nil_ffc;
17434 5267 temp_mapscr->ffcCountMarkDirty();
17435
2/2
✓ Branch 0 taken 5267 times.
✓ Branch 1 taken 6873 times.
12140 for(word m = 0; m < numffc; ++m)
17436 {
17437
1/2
✓ Branch 0 taken 6873 times.
✗ Branch 1 not taken.
6873 ffcdata& tempffc = (m < MAXFFCS)
17438 6873 ? temp_mapscr->ffcs[m]
17439 : nil_ffc; //sanity
17440 6873 tempffc.clear();
17441
3/4
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 6169 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 704 times.
6873 if(old_ff && !(bits & (1<<m))) continue;
17442
17443
1/2
✓ Branch 0 taken 6169 times.
✗ Branch 1 not taken.
6169 if(!p_igetw(&tempw,f,true))
17444 return qe_invalid;
17445
3/4
✓ Branch 0 taken 6169 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965 times.
✓ Branch 3 taken 5204 times.
6169 if(!old_ff && !tempw) //empty ffc, nothing more to load
17446 5204 continue;
17447 965 tempffc.setData(tempw);
17448
17449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempffc.cset),f,true))
17450 return qe_invalid;
17451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetw(&(tempffc.delay),f,true))
17452 return qe_invalid;
17453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.x),f,true))
17454 return qe_invalid;
17455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.y),f,true))
17456 return qe_invalid;
17457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.vx),f,true))
17458 return qe_invalid;
17459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.vy),f,true))
17460 return qe_invalid;
17461
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetzf(&(tempffc.ax),f,true))
17462 return qe_invalid;
17463
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetzf(&(tempffc.ay),f,true))
17464 return qe_invalid;
17465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempffc.link),f,true))
17466 return qe_invalid;
17467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(version < 24)
17468 {
17469 if(!p_getc(&tempbyte,f,true))
17470 return qe_invalid;
17471 tempffc.hxsz = (tempbyte&0x3F)+1;
17472 tempffc.txsz = (tempbyte>>6)+1;
17473 if(!p_getc(&tempbyte,f,true))
17474 return qe_invalid;
17475 tempffc.hysz = (tempbyte&0x3F)+1;
17476 tempffc.tysz = (tempbyte>>6)+1;
17477 }
17478 else
17479 {
17480
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetl(&(tempffc.hxsz),f,true))
17481 return qe_invalid;
17482
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetl(&(tempffc.hysz),f,true))
17483 return qe_invalid;
17484
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_getc(&(tempffc.txsz),f,true))
17485 return qe_invalid;
17486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempffc.tysz),f,true))
17487 return qe_invalid;
17488 }
17489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetl(&(tempffc.flags),f,true))
17490 return qe_invalid;
17491 965 tempffc.updateSolid();
17492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetw(&(tempffc.script),f,true))
17493 return qe_invalid;
17494
2/2
✓ Branch 0 taken 7720 times.
✓ Branch 1 taken 965 times.
8685 for(auto q = 0; q < 8; ++q)
17495 {
17496
1/2
✓ Branch 0 taken 7720 times.
✗ Branch 1 not taken.
7720 if(!p_igetl(&(tempffc.initd[q]),f,true))
17497 return qe_invalid;
17498 7720 }
17499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempbyte),f,true))
17500 return qe_invalid;
17501 965 tempffc.inita[0]=tempbyte*10000;
17502
17503
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_getc(&(tempbyte),f,true))
17504 return qe_invalid;
17505 965 tempffc.inita[1]=tempbyte*10000;
17506
17507 965 tempffc.initialized = false;
17508 965 }
17509
2/2
✓ Branch 0 taken 667303 times.
✓ Branch 1 taken 5267 times.
672570 for(word m = numffc; m < MAXFFCS; ++m)
17510 {
17511 667303 temp_mapscr->ffcs[m].clear();
17512 667303 }
17513 //END FFC
17514 }
17515 191379 return 0;
17516 199168 }
17517
17518
17519 109 int32_t readmaps(PACKFILE *f, zquestheader *Header, bool keepdata)
17520 {
17521 109 int32_t scr=0;
17522
17523 109 word version=0;
17524 dword dummy;
17525 int32_t screens_to_read;
17526
17527 109 mapscr temp_mapscr;
17528 zcmap temp_map;
17529 word temp_map_count;
17530 dword section_size;
17531
17532
3/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
109 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17533 {
17534 4 screens_to_read=MAPSCRS192b136;
17535 4 }
17536 else
17537 {
17538 105 screens_to_read=MAPSCRS;
17539 }
17540
17541
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
109 if(Header->zelda_version > 0x192)
17542 {
17543 //section version info
17544
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&version,f,true))
17545 {
17546 return qe_invalid;
17547 }
17548
17549 105 FFCore.quest_format[vMaps] = version;
17550
17551 //al_trace("Maps version %d\n", version);
17552
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&dummy,f,true))
17553 {
17554 return qe_invalid;
17555 }
17556
17557 //section size
17558
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&section_size,f,true))
17559 {
17560 return qe_invalid;
17561 }
17562
17563 //finally... section data
17564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(!p_igetw(&temp_map_count,f,true))
17565 {
17566 return 5;
17567 }
17568 105 }
17569 else
17570 {
17571 4 temp_map_count=map_count;
17572 }
17573
17574
17575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(keepdata)
17576 {
17577 109 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17578 109 TheMaps.resize(_mapsSize);
17579
17580
2/2
✓ Branch 0 taken 200328 times.
✓ Branch 1 taken 109 times.
200437 for(int32_t i(0); i<_mapsSize; i++)
17581 200328 TheMaps[i].zero_memory();
17582
17583 // Used to be done for each screen
17584
2/2
✓ Branch 0 taken 13952 times.
✓ Branch 1 taken 109 times.
14061 for(int32_t i=0; i<MAXFFCS; i++)
17585 {
17586 13952 ffcScriptData[i].a[0] = 10000;
17587 13952 ffcScriptData[i].a[1] = 10000;
17588 13952 }
17589
17590 109 memset(ZCMaps, 0, sizeof(zcmap)*MAXMAPS2);
17591 109 }
17592
17593 109 temp_mapscr.zero_memory();
17594
17595 109 memset(&temp_map, 0, sizeof(zcmap));
17596 109 temp_map.scrResWidth = 256;
17597 109 temp_map.scrResHeight = 224;
17598 109 temp_map.tileWidth = 16;
17599 109 temp_map.tileHeight = 11;
17600 109 temp_map.viewWidth = 256;
17601 109 temp_map.viewHeight = 176;
17602 109 temp_map.viewX = 0;
17603 109 temp_map.viewY = 64;
17604 109 temp_map.subaWidth = 256;
17605 109 temp_map.subaHeight = 168;
17606 109 temp_map.subaTrans = false;
17607 109 temp_map.subpWidth = 256;
17608 109 temp_map.subpHeight = 56;
17609 109 temp_map.subpTrans = false;
17610
4/4
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 1473 times.
✓ Branch 2 taken 1473 times.
✓ Branch 3 taken 109 times.
1582 for(int32_t i=0; i<temp_map_count && i<MAXMAPS2; i++)
17611 {
17612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1473 times.
1473 if(keepdata==true) //!TODO Trim fully
17613 {
17614 1473 memcpy(&ZCMaps[i], &temp_map, sizeof(zcmap));
17615 1473 }
17616 1473 byte valid=1;
17617
2/2
✓ Branch 0 taken 1370 times.
✓ Branch 1 taken 103 times.
1473 if(version > 22)
17618 {
17619
1/2
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
103 if(!p_getc(&valid,f,true))
17620 return qe_invalid;
17621 103 }
17622
2/2
✓ Branch 0 taken 200120 times.
✓ Branch 1 taken 1473 times.
201593 for(int32_t j=0; j<screens_to_read; j++)
17623 {
17624 200120 scr=i*MAPSCRS+j;
17625 200120 clear_screen(&temp_mapscr);
17626
2/2
✓ Branch 0 taken 952 times.
✓ Branch 1 taken 199168 times.
200120 if(valid)
17627 199168 readmapscreen(f, Header, &temp_mapscr, &temp_map, version);
17628
17629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200120 times.
200120 if(keepdata==true)
17630 {
17631 200120 TheMaps[scr] = temp_mapscr;
17632 200120 }
17633 200120 }
17634
17635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1473 times.
1473 if(keepdata==true)
17636 {
17637
3/6
✓ Branch 0 taken 1421 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1421 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1473 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17638 {
17639 52 int32_t index = (i*MAPSCRS+132);
17640
17641 52 TheMaps[index]=TheMaps[index-1];
17642
17643 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17644 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17645 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17646
17647
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 52 times.
208 for(int32_t j=133; j<MAPSCRS; j++)
17648 {
17649 156 scr=i*MAPSCRS+j;
17650
17651 156 TheMaps[scr].zero_memory();
17652 156 TheMaps[scr].valid = mVERSION;
17653 156 TheMaps[scr].screen_midi = -1;
17654 156 TheMaps[scr].csensitive = 1;
17655 156 }
17656 52 }
17657
17658
3/6
✓ Branch 0 taken 1421 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1421 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1473 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17659 {
17660
2/2
✓ Branch 0 taken 7072 times.
✓ Branch 1 taken 52 times.
7124 for(int32_t j=0; j<MAPSCRS; j++)
17661 {
17662 7072 scr=i*MAPSCRS+j;
17663 7072 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17664
17665
2/2
✓ Branch 0 taken 905216 times.
✓ Branch 1 taken 7072 times.
912288 for(int32_t k=0; k<128; k++)
17666 {
17667 905216 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17668 905216 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17669 905216 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17670 905216 }
17671 7072 }
17672 52 }
17673 1473 }
17674 1473 }
17675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(keepdata)
17676 {
17677 109 map_count = temp_map_count;
17678 109 }
17679 109 clear_screen(&temp_mapscr);
17680 109 return 0;
17681 109 }
17682
17683
17684 86 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos, bool keepdata)
17685 {
17686 86 reset_combo_animations();
17687 86 reset_combo_animations2();
17688
17689 86 init_combo_classes();
17690
17691 // combos
17692 86 word combos_used=0;
17693 int32_t dummy;
17694 byte padding;
17695 86 newcombo temp_combo;
17696 //word section_cversion=0;
17697
17698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 if(keepdata==true)
17699 {
17700
2/2
✓ Branch 0 taken 5614080 times.
✓ Branch 1 taken 86 times.
5614166 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17701 5614080 combobuf[q].clear();
17702 86 }
17703
17704 // if(version > 0x192)
17705 // {
17706 // //section version info
17707 // if(!p_igetw(&section_version,f,true))
17708 // {
17709 // return qe_invalid;
17710 // }
17711
17712 // FFCore.quest_format[vCombos] = section_version;
17713
17714 // //al_trace("Combos version %d\n", section_version);
17715 // if(!p_igetw(&section_cversion,f,true))
17716 // {
17717 // return qe_invalid;
17718 // }
17719
17720 // //section size
17721 // if(!p_igetl(&dummy,f,true))
17722 // {
17723 // return qe_invalid;
17724 // }
17725 // }
17726
17727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 if(version < 0x174)
17728 {
17729 combos_used=1024;
17730 }
17731
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 82 times.
86 else if(version < 0x191)
17732 {
17733 4 combos_used=2048;
17734 4 }
17735 else
17736 {
17737
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(!p_igetw(&combos_used,f,true))
17738 {
17739 return qe_invalid;
17740 }
17741 }
17742
17743 //finally... section data
17744
2/2
✓ Branch 0 taken 459323 times.
✓ Branch 1 taken 86 times.
459409 for(int32_t i=0; i<combos_used; i++)
17745 {
17746 459323 temp_combo.clear();
17747
17748
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 390439 times.
459323 if ( section_version >= 11 )
17749 {
17750
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.tile,f,true))
17751 {
17752 return qe_invalid;
17753 }
17754 68884 }
17755 else
17756 {
17757
1/2
✓ Branch 0 taken 390439 times.
✗ Branch 1 not taken.
390439 if(!p_igetw(&temp_combo.tile,f,true))
17758 {
17759 return qe_invalid;
17760 }
17761 }
17762 459323 temp_combo.o_tile = temp_combo.tile;
17763
1/2
✓ Branch 0 taken 459323 times.
✗ Branch 1 not taken.
459323 if(!p_getc(&temp_combo.flip,f,true))
17764 {
17765 return qe_invalid;
17766 }
17767
17768
1/2
✓ Branch 0 taken 459323 times.
✗ Branch 1 not taken.
459323 if(!p_getc(&temp_combo.walk,f,true))
17769 {
17770 return qe_invalid;
17771 }
17772
17773
1/2
✓ Branch 0 taken 459323 times.
✗ Branch 1 not taken.
459323 if(!p_getc(&temp_combo.type,f,true))
17774 {
17775 return qe_invalid;
17776 }
17777
17778
1/2
✓ Branch 0 taken 459323 times.
✗ Branch 1 not taken.
459323 if(!p_getc(&temp_combo.csets,f,true))
17779 {
17780 return qe_invalid;
17781 }
17782
17783
2/2
✓ Branch 0 taken 451131 times.
✓ Branch 1 taken 8192 times.
459323 if(version < 0x193)
17784 {
17785
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(!p_getc(&padding,f,true))
17786 return qe_invalid;
17787
17788
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(!p_getc(&padding,f,true))
17789 return qe_invalid;
17790
17791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8192 times.
8192 if(version < 0x192)
17792 {
17793
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(version == 0x191)
17794 {
17795 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17796 {
17797 if(!p_getc(&padding,f,true))
17798 return qe_invalid;
17799 }
17800 }
17801 8192 }
17802 8192 }
17803
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 451131 times.
459323 if(version >= 0x192)
17804 {
17805
1/2
✓ Branch 0 taken 451131 times.
✗ Branch 1 not taken.
451131 if(!p_getc(&temp_combo.frames,f,true))
17806 return qe_invalid;
17807
17808
1/2
✓ Branch 0 taken 451131 times.
✗ Branch 1 not taken.
451131 if(!p_getc(&temp_combo.speed,f,true))
17809 return qe_invalid;
17810
17811
1/2
✓ Branch 0 taken 451131 times.
✗ Branch 1 not taken.
451131 if(!p_igetw(&temp_combo.nextcombo,f,true))
17812 return qe_invalid;
17813
17814
1/2
✓ Branch 0 taken 451131 times.
✗ Branch 1 not taken.
451131 if(!p_getc(&temp_combo.nextcset,f,true))
17815 return qe_invalid;
17816
17817 //Base flag
17818
2/2
✓ Branch 0 taken 109114 times.
✓ Branch 1 taken 342017 times.
451131 if(section_version>=3)
17819
1/2
✓ Branch 0 taken 342017 times.
✗ Branch 1 not taken.
342017 if(!p_getc(&temp_combo.flag,f,true))
17820 return qe_invalid;
17821
17822
2/2
✓ Branch 0 taken 109114 times.
✓ Branch 1 taken 342017 times.
451131 if(section_version>=4)
17823 {
17824
1/2
✓ Branch 0 taken 342017 times.
✗ Branch 1 not taken.
342017 if(!p_getc(&temp_combo.skipanim,f,true))
17825 return qe_invalid;
17826
17827
1/2
✓ Branch 0 taken 342017 times.
✗ Branch 1 not taken.
342017 if(!p_igetw(&temp_combo.nexttimer,f,true))
17828 return qe_invalid;
17829 342017 }
17830
17831
2/2
✓ Branch 0 taken 109114 times.
✓ Branch 1 taken 342017 times.
451131 if(section_version>=5)
17832
1/2
✓ Branch 0 taken 342017 times.
✗ Branch 1 not taken.
342017 if(!p_getc(&temp_combo.skipanimy,f,true))
17833 return qe_invalid;
17834
17835
2/2
✓ Branch 0 taken 109114 times.
✓ Branch 1 taken 342017 times.
451131 if(section_version>=6)
17836 {
17837
1/2
✓ Branch 0 taken 342017 times.
✗ Branch 1 not taken.
342017 if(!p_getc(&temp_combo.animflags,f,true))
17838 return qe_invalid;
17839
17840
1/2
✓ Branch 0 taken 342017 times.
✗ Branch 1 not taken.
342017 if(section_version == 6)
17841 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17842 342017 }
17843
17844
2/2
✓ Branch 0 taken 382247 times.
✓ Branch 1 taken 68884 times.
451131 if(section_version>=8) //combo Attributes[4] and userflags.
17845 {
17846
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17847
1/2
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
275536 if(!p_igetl(&temp_combo.attributes[q],f,true))
17848 return qe_invalid;
17849
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.usrflags,f,true))
17850 return qe_invalid;
17851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68884 times.
68884 if(section_version >= 20)
17852
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetw(&temp_combo.genflags,f,true))
17853 return qe_invalid;
17854 68884 }
17855
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 382247 times.
451131 if(section_version>=10) //combo trigger flags
17856 {
17857
2/2
✓ Branch 0 taken 206652 times.
✓ Branch 1 taken 68884 times.
275536 for ( int32_t q = 0; q < 3; q++ )
17858
1/2
✓ Branch 0 taken 206652 times.
✗ Branch 1 not taken.
206652 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17859 return qe_invalid;
17860 68884 }
17861
1/2
✓ Branch 0 taken 382247 times.
✗ Branch 1 not taken.
382247 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17862 {
17863 for ( int32_t q = 0; q < 2; q++ )
17864 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17865 return qe_invalid;
17866 }
17867
2/2
✓ Branch 0 taken 382247 times.
✓ Branch 1 taken 68884 times.
451131 if(section_version >= 9)
17868
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.triggerlevel,f,true))
17869 return qe_invalid;
17870
2/2
✓ Branch 0 taken 382247 times.
✓ Branch 1 taken 68884 times.
451131 if(section_version >= 22)
17871
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_getc(&temp_combo.triggerbtn,f,true))
17872 return qe_invalid;
17873
1/2
✓ Branch 0 taken 451131 times.
✗ Branch 1 not taken.
451131 if(section_version >= 24)
17874 {
17875 if(!p_getc(&temp_combo.triggeritem,f,true))
17876 return qe_invalid;
17877 if(!p_getc(&temp_combo.trigtimer,f,true))
17878 return qe_invalid;
17879 }
17880
1/2
✓ Branch 0 taken 451131 times.
✗ Branch 1 not taken.
451131 if(section_version >= 25)
17881 if(!p_getc(&temp_combo.trigsfx,f,true))
17882 return qe_invalid;
17883
1/2
✓ Branch 0 taken 451131 times.
✗ Branch 1 not taken.
451131 if(section_version >= 27)
17884 if(!p_igetl(&temp_combo.trigchange,f,true))
17885 return qe_invalid;
17886
17887
1/2
✓ Branch 0 taken 451131 times.
✗ Branch 1 not taken.
451131 if(section_version >= 29)
17888 {
17889 if(!p_igetw(&temp_combo.trigprox,f,true))
17890 return qe_invalid;
17891 if(!p_getc(&temp_combo.trigctr,f,true))
17892 return qe_invalid;
17893 if(!p_igetl(&temp_combo.trigctramnt,f,true))
17894 return qe_invalid;
17895 }
17896
1/2
✓ Branch 0 taken 451131 times.
✗ Branch 1 not taken.
451131 if(section_version >= 30)
17897 if(!p_getc(&temp_combo.triglbeam,f,true))
17898 return qe_invalid;
17899
1/2
✓ Branch 0 taken 451131 times.
✗ Branch 1 not taken.
451131 if(section_version >= 31)
17900 {
17901 if(!p_getc(&temp_combo.trigcschange,f,true))
17902 return qe_invalid;
17903 if(!p_igetw(&temp_combo.spawnitem,f,true))
17904 return qe_invalid;
17905 if(!p_igetw(&temp_combo.spawnenemy,f,true))
17906 return qe_invalid;
17907 if(!p_getc(&temp_combo.exstate,f,true))
17908 return qe_invalid;
17909 if(!p_igetl(&temp_combo.spawnip,f,true))
17910 return qe_invalid;
17911 if(!p_getc(&temp_combo.trigcopycat,f,true))
17912 return qe_invalid;
17913 }
17914
1/2
✓ Branch 0 taken 451131 times.
✗ Branch 1 not taken.
451131 if(section_version >= 32)
17915 if(!p_getc(&temp_combo.trigcooldown,f,true))
17916 return qe_invalid;
17917
17918
2/2
✓ Branch 0 taken 382247 times.
✓ Branch 1 taken 68884 times.
451131 if(section_version>=12) //combo label
17919
2/2
✓ Branch 0 taken 757724 times.
✓ Branch 1 taken 68884 times.
826608 for ( int32_t q = 0; q < 11; q++ )
17920
1/2
✓ Branch 0 taken 757724 times.
✗ Branch 1 not taken.
757724 if(!p_getc(&temp_combo.label[q],f,true))
17921 68884 return qe_invalid;
17922
2/2
✓ Branch 0 taken 382247 times.
✓ Branch 1 taken 68884 times.
451131 if(section_version>=13) //attribytes[4]
17923
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < 4; q++ )
17924
1/2
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f,true))
17925 68884 return qe_invalid;
17926 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17927 * This fixes a poor implementation of a ->next flag bug thing.
17928 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17929 * there was a version bump a few weeks before a change that broke stuff.
17930 */
17931
3/4
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 382247 times.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
451131 if (section_version >= 13 && section_version < 21)
17932 {
17933 set_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17934 }
17935 //combo scripts
17936
2/2
✓ Branch 0 taken 382247 times.
✓ Branch 1 taken 68884 times.
451131 if(section_version>=14)
17937 {
17938
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetw(&temp_combo.script,f,true))
17939 return qe_invalid;
17940
2/2
✓ Branch 0 taken 137768 times.
✓ Branch 1 taken 68884 times.
206652 for ( int32_t q = 0; q < 2; q++ )
17941
1/2
✓ Branch 0 taken 137768 times.
✗ Branch 1 not taken.
137768 if(!p_igetl(&temp_combo.initd[q],f,true))
17942 return qe_invalid;
17943 68884 }
17944 //al_trace("Read combo script data\n");
17945
2/2
✓ Branch 0 taken 382247 times.
✓ Branch 1 taken 68884 times.
451131 if(section_version>=15)
17946 {
17947
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.o_tile,f,true)) return qe_invalid;
17948
2/2
✓ Branch 0 taken 37028 times.
✓ Branch 1 taken 31856 times.
68884 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17949
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_getc(&temp_combo.cur_frame,f,true)) return qe_invalid;
17950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68884 times.
68884 if(!p_getc(&temp_combo.aclk,f,true)) return qe_invalid;
17951 68884 }
17952
2/2
✓ Branch 0 taken 382247 times.
✓ Branch 1 taken 68884 times.
451131 if(section_version>=17) //attribytes[4]
17953 {
17954
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17955
1/2
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f,true))
17956 return qe_invalid;
17957
2/2
✓ Branch 0 taken 551072 times.
✓ Branch 1 taken 68884 times.
619956 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17958
1/2
✓ Branch 0 taken 551072 times.
✗ Branch 1 not taken.
551072 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
17959 return qe_invalid;
17960 68884 }
17961
17962
1/2
✓ Branch 0 taken 451131 times.
✗ Branch 1 not taken.
451131 if(version < 0x193)
17963 for(int32_t q=0; q<11; q++)
17964 if(!p_getc(&dummy,f,true))
17965 return qe_invalid;
17966 451131 }
17967
17968 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17969
3/6
✓ Branch 0 taken 342017 times.
✓ Branch 1 taken 117306 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 342017 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
459323 if((version < 0x211)||((version == 0x211)&&(build<7)))
17970 {
17971
2/2
✓ Branch 0 taken 109114 times.
✓ Branch 1 taken 8192 times.
117306 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
17972 {
17973
1/5
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
8192 switch(temp_combo.tile)
17974 {
17975 case 130:
17976 temp_combo.tile = 132;
17977 break;
17978
17979 case 131:
17980 temp_combo.tile = 133;
17981 break;
17982
17983 case 132:
17984 temp_combo.tile = 130;
17985 break;
17986
17987 case 133:
17988 temp_combo.tile = 131;
17989 break;
17990 }
17991 8192 }
17992 117306 }
17993
17994
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 390439 times.
459323 if(section_version < 15)
17995 390439 temp_combo.o_tile = temp_combo.tile;
17996
17997
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 390439 times.
459323 if(section_version<18) //upper bits for .walk
17998 390439 temp_combo.walk |= 0xF0;
17999
18000
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 390439 times.
459323 if(section_version < 19)
18001
2/2
✓ Branch 0 taken 1561756 times.
✓ Branch 1 taken 390439 times.
1952195 for(int32_t q = 0; q < 4; ++q)
18002 1952195 temp_combo.attributes[q] *= 10000L;
18003
18004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459323 times.
459323 if(section_version < 23)
18005 {
18006
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 459053 times.
459323 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
18007 {
18008 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
18009 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
18010 case cTRIGGERGENERIC: case cCSWITCH:
18011 270 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
18012 270 }
18013 459323 }
18014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459323 times.
459323 if(section_version < 25)
18015 {
18016
2/2
✓ Branch 0 taken 2587 times.
✓ Branch 1 taken 456736 times.
459323 switch(temp_combo.type)
18017 {
18018 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
18019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2587 times.
2587 if(!(temp_combo.usrflags & cflag3))
18020 2587 temp_combo.attribytes[3] = WAV_DOOR;
18021 2587 temp_combo.usrflags &= ~cflag3;
18022 2587 break;
18023 }
18024 459323 }
18025
18026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459323 times.
459323 if(section_version < 26)
18027
2/2
✓ Branch 0 taken 458795 times.
✓ Branch 1 taken 528 times.
459851 if(temp_combo.type == cARMOS)
18028
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 if(temp_combo.usrflags & cflag1)
18029 temp_combo.usrflags |= cflag3;
18030
18031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459323 times.
459323 if(section_version < 27)
18032 {
18033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459323 times.
459323 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
18034 temp_combo.trigchange = 1;
18035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459323 times.
459323 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
18036 temp_combo.trigchange = -1;
18037 459323 else temp_combo.trigchange = 0;
18038 459323 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
18039 459323 }
18040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 459323 times.
459323 if(section_version < 28)
18041 {
18042
2/2
✓ Branch 0 taken 1376 times.
✓ Branch 1 taken 457947 times.
459323 switch(temp_combo.type)
18043 {
18044 case cLOCKBLOCK: case cLOCKEDCHEST:
18045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1376 times.
1376 if(temp_combo.usrflags & cflag7)
18046 temp_combo.usrflags |= cflag8;
18047 1376 else temp_combo.usrflags &= ~cflag8;
18048 1376 temp_combo.usrflags &= ~cflag7;
18049 1376 break;
18050 }
18051
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 459257 times.
459323 switch(temp_combo.type)
18052 {
18053 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
18054 66 temp_combo.attrishorts[2] = -1;
18055 66 temp_combo.usrflags |= cflag7;
18056 66 break;
18057 }
18058 459323 }
18059
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 390439 times.
459323 if(section_version < 20)
18060 {
18061 390439 temp_combo.genflags = 0;
18062
2/2
✓ Branch 0 taken 17402 times.
✓ Branch 1 taken 373037 times.
390439 switch(temp_combo.type)
18063 {
18064 case cPUSH_WAIT: case cPUSH_HEAVY:
18065 case cPUSH_HW: case cL_STATUE:
18066 case cR_STATUE: case cPUSH_HEAVY2:
18067 case cPUSH_HW2: case cPOUND:
18068 case cC_STATUE: case cMIRROR:
18069 case cMIRRORSLASH: case cMIRRORBACKSLASH:
18070 case cMAGICPRISM: case cMAGICPRISM4:
18071 case cMAGICSPONGE: case cEYEBALL_A:
18072 case cEYEBALL_B: case cEYEBALL_4:
18073 case cBUSH: case cFLOWERS:
18074 case cLOCKBLOCK: case cLOCKBLOCK2:
18075 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
18076 case cCHEST: case cCHEST2:
18077 case cLOCKEDCHEST: case cLOCKEDCHEST2:
18078 case cBOSSCHEST: case cBOSSCHEST2:
18079 case cBUSHNEXT: case cBUSHTOUCHY:
18080 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
18081 case cSIGNPOST: case cCSWITCHBLOCK:
18082 case cTORCH: case cTRIGGERGENERIC:
18083
1/2
✓ Branch 0 taken 17402 times.
✗ Branch 1 not taken.
17402 if(temp_combo.usrflags & cflag16)
18084 {
18085 temp_combo.genflags |= cflag1;
18086 temp_combo.usrflags &= ~cflag16;
18087 }
18088 17402 break;
18089 }
18090 390439 }
18091
18092
2/4
✓ Branch 0 taken 459323 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 459323 times.
459323 if(keepdata==true && i>=start_combo)
18093 {
18094 459323 combobuf[i] = temp_combo;
18095 459323 }
18096 459323 }
18097
18098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 if(keepdata==true)
18099 {
18100
3/6
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 82 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
86 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
18101 {
18102
2/2
✓ Branch 0 taken 261120 times.
✓ Branch 1 taken 4 times.
261124 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18103 {
18104
1/2
✓ Branch 0 taken 261120 times.
✗ Branch 1 not taken.
261120 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
18105 {
18106 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
18107 }
18108 261120 }
18109 4 }
18110
18111 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
18112
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 81 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
86 if(version == 0x210 && !is_zquest())
18113 {
18114
2/2
✓ Branch 0 taken 326400 times.
✓ Branch 1 taken 5 times.
326405 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18115
2/2
✓ Branch 0 taken 326398 times.
✓ Branch 1 taken 2 times.
326402 if(combobuf[tmpcounter].type == cLADDERONLY)
18116 2 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
18117 5 }
18118
18119
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 9 times.
86 if(section_version<7)
18120 {
18121
2/2
✓ Branch 0 taken 587520 times.
✓ Branch 1 taken 9 times.
587529 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18122 {
18123
6/9
✓ Branch 0 taken 587349 times.
✓ Branch 1 taken 61 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 10 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
587520 switch(combobuf[tmpcounter].type)
18124 {
18125 case cSLASH:
18126 61 combobuf[tmpcounter].type=cSLASHTOUCHY;
18127 61 break;
18128
18129 case cSLASHITEM:
18130 62 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
18131 62 break;
18132
18133 case cBUSH:
18134 28 combobuf[tmpcounter].type=cBUSHTOUCHY;
18135 28 break;
18136
18137 case cFLOWERS:
18138 10 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
18139 10 break;
18140
18141 case cTALLGRASS:
18142 10 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
18143 10 break;
18144
18145 case cSLASHNEXT:
18146 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
18147 break;
18148
18149 case cSLASHNEXTITEM:
18150 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
18151 break;
18152
18153 case cBUSHNEXT:
18154 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
18155 break;
18156 }
18157 587520 }
18158 9 }
18159
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 84 times.
86 if (section_version < 16)
18160 {
18161
2/2
✓ Branch 0 taken 5483520 times.
✓ Branch 1 taken 84 times.
5483604 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18162 {
18163
2/2
✓ Branch 0 taken 5477912 times.
✓ Branch 1 taken 5608 times.
5483520 if (combobuf[tmpcounter].type == cWATER)
18164 {
18165 5608 combobuf[tmpcounter].attributes[0] = 40000L;
18166 5608 }
18167 5483520 }
18168 84 }
18169
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 1 times.
86 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18170 {
18171 1 combobuf[0].walk = 0xF0;
18172 1 combobuf[0].type = 0;
18173 1 combobuf[0].flag = 0;
18174 1 }
18175 86 }
18176
18177 //Now for the new combo alias reset
18178
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
86 if(section_version<2 && keepdata)
18179 {
18180
2/2
✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9 times.
73737 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18181 {
18182 73728 combo_aliases[j].width = 0;
18183 73728 combo_aliases[j].height = 0;
18184 73728 combo_aliases[j].layermask = 0;
18185
18186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73728 times.
73728 if(combo_aliases[j].combos != NULL)
18187 {
18188
1/2
✓ Branch 0 taken 73728 times.
✗ Branch 1 not taken.
73728 delete[] combo_aliases[j].combos;
18189 73728 }
18190
18191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73728 times.
73728 if(combo_aliases[j].csets != NULL)
18192 {
18193
1/2
✓ Branch 0 taken 73728 times.
✗ Branch 1 not taken.
73728 delete[] combo_aliases[j].csets;
18194 73728 }
18195
18196 73728 combo_aliases[j].combos = new word[1];
18197 73728 combo_aliases[j].csets = new byte[1];
18198 73728 combo_aliases[j].combos[0] = 0;
18199 73728 combo_aliases[j].csets[0] = 0;
18200 73728 }
18201 9 }
18202
18203
18204 86 setup_combo_animations();
18205 86 setup_combo_animations2();
18206 86 return 0;
18207 86 }
18208 146870 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18209 {
18210 byte combo_has_flags;
18211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146870 times.
146870 if(!p_getc(&combo_has_flags,f,true))
18212 return qe_invalid;
18213
18214 146870 temp_combo.clear();
18215
2/2
✓ Branch 0 taken 95340 times.
✓ Branch 1 taken 51530 times.
146870 if(combo_has_flags)
18216 {
18217
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 51527 times.
51530 if(combo_has_flags&CHAS_BASIC)
18218 {
18219
1/2
✓ Branch 0 taken 51527 times.
✗ Branch 1 not taken.
51527 if(!p_igetl(&temp_combo.tile,f,true))
18220 {
18221 return qe_invalid;
18222 }
18223 51527 temp_combo.o_tile = temp_combo.tile;
18224
18225
1/2
✓ Branch 0 taken 51527 times.
✗ Branch 1 not taken.
51527 if(!p_getc(&temp_combo.flip,f,true))
18226 {
18227 return qe_invalid;
18228 }
18229
18230
1/2
✓ Branch 0 taken 51527 times.
✗ Branch 1 not taken.
51527 if(!p_getc(&temp_combo.walk,f,true))
18231 {
18232 return qe_invalid;
18233 }
18234
18235
1/2
✓ Branch 0 taken 51527 times.
✗ Branch 1 not taken.
51527 if(!p_getc(&temp_combo.type,f,true))
18236 {
18237 return qe_invalid;
18238 }
18239
18240
1/2
✓ Branch 0 taken 51527 times.
✗ Branch 1 not taken.
51527 if(!p_getc(&temp_combo.flag,f,true))
18241 {
18242 return qe_invalid;
18243 }
18244
18245
1/2
✓ Branch 0 taken 51527 times.
✗ Branch 1 not taken.
51527 if(!p_getc(&temp_combo.csets,f,true))
18246 {
18247 return qe_invalid;
18248 }
18249 51527 }
18250
2/2
✓ Branch 0 taken 51506 times.
✓ Branch 1 taken 24 times.
51530 if(combo_has_flags&CHAS_SCRIPT)
18251 {
18252
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 24 times.
288 for ( int32_t q = 0; q < 11; q++ )
18253 {
18254
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(!p_getc(&temp_combo.label[q],f,true))
18255 {
18256 return qe_invalid;
18257 }
18258 264 }
18259
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&temp_combo.script,f,true)) return qe_invalid;
18260
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 24 times.
72 for ( int32_t q = 0; q < 2; q++ )
18261 {
18262
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(!p_igetl(&temp_combo.initd[q],f,true))
18263 {
18264 return qe_invalid;
18265 }
18266 48 }
18267 24 }
18268
2/2
✓ Branch 0 taken 37713 times.
✓ Branch 1 taken 13817 times.
51530 if(combo_has_flags&CHAS_ANIM)
18269 {
18270
1/2
✓ Branch 0 taken 13817 times.
✗ Branch 1 not taken.
13817 if(!p_getc(&temp_combo.frames,f,true))
18271 {
18272 return qe_invalid;
18273 }
18274
18275
1/2
✓ Branch 0 taken 13817 times.
✗ Branch 1 not taken.
13817 if(!p_getc(&temp_combo.speed,f,true))
18276 {
18277 return qe_invalid;
18278 }
18279
18280
1/2
✓ Branch 0 taken 13817 times.
✗ Branch 1 not taken.
13817 if(!p_igetw(&temp_combo.nextcombo,f,true))
18281 {
18282 return qe_invalid;
18283 }
18284
18285
1/2
✓ Branch 0 taken 13817 times.
✗ Branch 1 not taken.
13817 if(!p_getc(&temp_combo.nextcset,f,true))
18286 {
18287 return qe_invalid;
18288 }
18289
18290
1/2
✓ Branch 0 taken 13817 times.
✗ Branch 1 not taken.
13817 if(!p_getc(&temp_combo.skipanim,f,true))
18291 {
18292 return qe_invalid;
18293 }
18294
18295
1/2
✓ Branch 0 taken 13817 times.
✗ Branch 1 not taken.
13817 if(!p_getc(&temp_combo.skipanimy,f,true))
18296 {
18297 return qe_invalid;
18298 }
18299
18300
1/2
✓ Branch 0 taken 13817 times.
✗ Branch 1 not taken.
13817 if(!p_getc(&temp_combo.animflags,f,true))
18301 {
18302 return qe_invalid;
18303 }
18304 13817 }
18305
2/2
✓ Branch 0 taken 46803 times.
✓ Branch 1 taken 4727 times.
51530 if(combo_has_flags&CHAS_ATTRIB)
18306 {
18307
2/2
✓ Branch 0 taken 18908 times.
✓ Branch 1 taken 4727 times.
23635 for ( int32_t q = 0; q < 4; q++ )
18308 {
18309
1/2
✓ Branch 0 taken 18908 times.
✗ Branch 1 not taken.
18908 if(!p_igetl(&temp_combo.attributes[q],f,true))
18310 {
18311 return qe_invalid;
18312 }
18313 18908 }
18314
2/2
✓ Branch 0 taken 37816 times.
✓ Branch 1 taken 4727 times.
42543 for ( int32_t q = 0; q < 8; q++ )
18315 {
18316
1/2
✓ Branch 0 taken 37816 times.
✗ Branch 1 not taken.
37816 if(!p_getc(&temp_combo.attribytes[q],f,true))
18317 {
18318 return qe_invalid;
18319 }
18320 37816 }
18321
2/2
✓ Branch 0 taken 37816 times.
✓ Branch 1 taken 4727 times.
42543 for ( int32_t q = 0; q < 8; q++ )
18322 {
18323
1/2
✓ Branch 0 taken 37816 times.
✗ Branch 1 not taken.
37816 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
18324 {
18325 return qe_invalid;
18326 }
18327 37816 }
18328 4727 }
18329
2/2
✓ Branch 0 taken 49987 times.
✓ Branch 1 taken 1543 times.
51530 if(combo_has_flags&CHAS_FLAG)
18330 {
18331
1/2
✓ Branch 0 taken 1543 times.
✗ Branch 1 not taken.
1543 if(!p_igetl(&temp_combo.usrflags,f,true))
18332 {
18333 return qe_invalid;
18334 }
18335
1/2
✓ Branch 0 taken 1543 times.
✗ Branch 1 not taken.
1543 if(!p_igetw(&temp_combo.genflags,f,true))
18336 {
18337 return qe_invalid;
18338 }
18339 1543 }
18340
2/2
✓ Branch 0 taken 51080 times.
✓ Branch 1 taken 450 times.
51530 if(combo_has_flags&CHAS_TRIG)
18341 {
18342 450 int numtrigs = s_version < 36 ? 3 : 6;
18343
2/2
✓ Branch 0 taken 2103 times.
✓ Branch 1 taken 450 times.
2553 for ( int32_t q = 0; q < numtrigs; q++ )
18344 {
18345
1/2
✓ Branch 0 taken 2103 times.
✗ Branch 1 not taken.
2103 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
18346 {
18347 return qe_invalid;
18348 }
18349 2103 }
18350
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 if(!p_igetl(&temp_combo.triggerlevel,f,true))
18351 {
18352 return qe_invalid;
18353 }
18354
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 if(!p_getc(&temp_combo.triggerbtn,f,true))
18355 {
18356 return qe_invalid;
18357 }
18358
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 if(!p_getc(&temp_combo.triggeritem,f,true))
18359 {
18360 return qe_invalid;
18361 }
18362
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 if(!p_getc(&temp_combo.trigtimer,f,true))
18363 {
18364 return qe_invalid;
18365 }
18366
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 if(!p_getc(&temp_combo.trigsfx,f,true))
18367 {
18368 return qe_invalid;
18369 }
18370
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 if(!p_igetl(&temp_combo.trigchange,f,true))
18371 {
18372 return qe_invalid;
18373 }
18374
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 if(!p_igetw(&temp_combo.trigprox,f,true))
18375 {
18376 return qe_invalid;
18377 }
18378
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 if(!p_getc(&temp_combo.trigctr,f,true))
18379 {
18380 return qe_invalid;
18381 }
18382
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 if(!p_igetl(&temp_combo.trigctramnt,f,true))
18383 {
18384 return qe_invalid;
18385 }
18386
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 if(!p_getc(&temp_combo.triglbeam,f,true))
18387 {
18388 return qe_invalid;
18389 }
18390
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 if(!p_getc(&temp_combo.trigcschange,f,true))
18391 {
18392 return qe_invalid;
18393 }
18394
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 if(!p_igetw(&temp_combo.spawnitem,f,true))
18395 {
18396 return qe_invalid;
18397 }
18398
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 if(!p_igetw(&temp_combo.spawnenemy,f,true))
18399 {
18400 return qe_invalid;
18401 }
18402
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 if(!p_getc(&temp_combo.exstate,f,true))
18403 {
18404 return qe_invalid;
18405 }
18406
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 if(!p_igetl(&temp_combo.spawnip,f,true))
18407 {
18408 return qe_invalid;
18409 }
18410
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 if(!p_getc(&temp_combo.trigcopycat,f,true))
18411 {
18412 return qe_invalid;
18413 }
18414
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 if(!p_getc(&temp_combo.trigcooldown,f,true))
18415 {
18416 return qe_invalid;
18417 }
18418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 450 times.
450 if(s_version >= 35)
18419 {
18420
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 if(!p_igetw(&temp_combo.prompt_cid,f,true))
18421 {
18422 return qe_invalid;
18423 }
18424
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 if(!p_getc(&temp_combo.prompt_cs,f,true))
18425 {
18426 return qe_invalid;
18427 }
18428
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 if(!p_igetw(&temp_combo.prompt_x,f,true))
18429 {
18430 return qe_invalid;
18431 }
18432
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 if(!p_igetw(&temp_combo.prompt_y,f,true))
18433 {
18434 return qe_invalid;
18435 }
18436 450 }
18437
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 251 times.
450 if(s_version >= 36)
18438 {
18439
1/2
✓ Branch 0 taken 251 times.
✗ Branch 1 not taken.
251 if(!p_getc(&temp_combo.trig_lstate,f,true))
18440 {
18441 return qe_invalid;
18442 }
18443
1/2
✓ Branch 0 taken 251 times.
✗ Branch 1 not taken.
251 if(!p_getc(&temp_combo.trig_gstate,f,true))
18444 {
18445 return qe_invalid;
18446 }
18447
1/2
✓ Branch 0 taken 251 times.
✗ Branch 1 not taken.
251 if(!p_igetl(&temp_combo.trig_statetime,f,true))
18448 {
18449 return qe_invalid;
18450 }
18451 251 }
18452
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 251 times.
450 if(s_version >= 37)
18453 {
18454
1/2
✓ Branch 0 taken 251 times.
✗ Branch 1 not taken.
251 if(!p_igetw(&temp_combo.trig_genscr,f,true))
18455 {
18456 return qe_invalid;
18457 }
18458 251 }
18459
2/2
✓ Branch 0 taken 273 times.
✓ Branch 1 taken 177 times.
450 if(s_version >= 38)
18460 {
18461
1/2
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
177 if(!p_getc(&temp_combo.trig_group,f,true))
18462 {
18463 return qe_invalid;
18464 }
18465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
177 if(!p_igetw(&temp_combo.trig_group_val,f,true))
18466 {
18467 return qe_invalid;
18468 }
18469 177 }
18470 450 }
18471
2/2
✓ Branch 0 taken 51427 times.
✓ Branch 1 taken 103 times.
51530 if(combo_has_flags&CHAS_LIFT)
18472 {
18473
1/2
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
103 if(!p_igetw(&temp_combo.liftcmb,f,true))
18474 return qe_invalid;
18475
1/2
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
103 if(!p_getc(&temp_combo.liftcs,f,true))
18476 return qe_invalid;
18477
1/2
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
103 if(!p_igetw(&temp_combo.liftundercmb,f,true))
18478 return qe_invalid;
18479
1/2
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
103 if(!p_getc(&temp_combo.liftundercs,f,true))
18480 return qe_invalid;
18481
1/2
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
103 if(!p_getc(&temp_combo.liftdmg,f,true))
18482 return qe_invalid;
18483
1/2
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
103 if(!p_getc(&temp_combo.liftlvl,f,true))
18484 return qe_invalid;
18485
1/2
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
103 if(!p_getc(&temp_combo.liftitm,f,true))
18486 return qe_invalid;
18487
1/2
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
103 if(!p_getc(&temp_combo.liftflags,f,true))
18488 return qe_invalid;
18489
1/2
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
103 if(!p_getc(&temp_combo.liftgfx,f,true))
18490 return qe_invalid;
18491
1/2
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
103 if(!p_getc(&temp_combo.liftsprite,f,true))
18492 return qe_invalid;
18493
1/2
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
103 if(!p_getc(&temp_combo.liftsfx,f,true))
18494 return qe_invalid;
18495
1/2
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
103 if(!p_igetw(&temp_combo.liftbreaksprite,f,true))
18496 return qe_invalid;
18497
1/2
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
103 if(!p_getc(&temp_combo.liftbreaksfx,f,true))
18498 return qe_invalid;
18499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 if(s_version >= 34)
18500 {
18501
1/2
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
103 if(!p_getc(&temp_combo.lifthei,f,true))
18502 return qe_invalid;
18503
1/2
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
103 if(!p_getc(&temp_combo.lifttime,f,true))
18504 return qe_invalid;
18505 103 }
18506
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 48 times.
103 if(s_version >= 39)
18507 {
18508
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(!p_getc(&temp_combo.lift_parent_item,f,true))
18509 return qe_invalid;
18510 48 }
18511 103 }
18512
2/2
✓ Branch 0 taken 51514 times.
✓ Branch 1 taken 16 times.
51530 if(combo_has_flags&CHAS_GENERAL)
18513 {
18514
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_combo.speed_mult,f,true))
18515 return qe_invalid;
18516
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_combo.speed_div,f,true))
18517 return qe_invalid;
18518
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetzf(&temp_combo.speed_add,f,true))
18519 return qe_invalid;
18520 16 }
18521 51530 }
18522 146870 return 0;
18523 146870 }
18524 109 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos, bool keepdata)
18525 {
18526 109 word section_version=0;
18527 109 word section_cversion=0;
18528 109 word combos_used=0;
18529 int32_t dummy;
18530 byte padding;
18531 109 newcombo temp_combo;
18532
18533 109 reset_combo_animations();
18534 109 reset_combo_animations2();
18535 109 init_combo_classes();
18536
18537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(keepdata==true) //reset combos
18538 {
18539
2/2
✓ Branch 0 taken 7115520 times.
✓ Branch 1 taken 109 times.
7115629 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18540 7115520 combobuf[q].clear();
18541 109 }
18542
18543
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 105 times.
109 if(version > 0x192) //Version info
18544 {
18545
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&section_version,f,true))
18546 {
18547 return qe_invalid;
18548 }
18549 105 FFCore.quest_format[vCombos] = section_version;
18550
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&section_cversion,f,true))
18551 {
18552 return qe_invalid;
18553 }
18554
18555 //section size
18556
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy,f,true))
18557 {
18558 return qe_invalid;
18559 }
18560 105 }
18561
18562
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 86 times.
109 if(section_version > 32) //Cleanup time!
18563 {
18564
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetw(&combos_used,f,true))
18565 {
18566 return qe_invalid;
18567 }
18568
2/2
✓ Branch 0 taken 146870 times.
✓ Branch 1 taken 23 times.
146893 for(int32_t i=0; i<combos_used; i++)
18569 {
18570 146870 auto ret = readcombo_loop(f,section_version,temp_combo);
18571
1/2
✓ Branch 0 taken 146870 times.
✗ Branch 1 not taken.
146870 if(ret) return ret;
18572
2/4
✓ Branch 0 taken 146870 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 146870 times.
146870 if(keepdata==true && i>=start_combo)
18573 146870 memcpy(&combobuf[i], &temp_combo, sizeof(temp_combo));
18574 146870 }
18575 23 }
18576 else //Call the old function for all old versions
18577 {
18578 86 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos,keepdata);
18579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 if(ret) return ret; //error, end read
18580 }
18581
18582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(keepdata==true)
18583 {
18584
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 86 times.
109 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18585 {
18586 23 combobuf[0].walk = 0xF0;
18587 23 combobuf[0].type = 0;
18588 23 combobuf[0].flag = 0;
18589 23 }
18590 109 }
18591
18592 109 setup_combo_animations();
18593 109 setup_combo_animations2();
18594 109 return 0;
18595 109 }
18596
18597 100 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build, bool keepdata)
18598 {
18599 //these are here to bypass compiler warnings about unused arguments
18600 100 Header=Header;
18601 100 version=version;
18602 100 build=build;
18603
18604 int32_t dummy;
18605 100 word sversion=0, c_sversion;
18606
18607 //section version info
18608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_igetw(&sversion,f,true))
18609 {
18610 return qe_invalid;
18611 }
18612
18613 100 FFCore.quest_format[vComboAliases] = sversion;
18614
18615 //al_trace("Combo aliases version %d\n", sversion);
18616
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetw(&c_sversion,f,true))
18617 {
18618 return qe_invalid;
18619 }
18620
18621 //section size
18622
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&dummy,f,true))
18623 {
18624 return qe_invalid;
18625 }
18626
18627 100 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18628
18629
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 75 times.
100 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18630 {
18631 75 max_num_combo_aliases = MAX250COMBOALIASES;
18632 75 }
18633
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18634 {
18635 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18636 }
18637
18638
2/2
✓ Branch 0 taken 358400 times.
✓ Branch 1 taken 100 times.
358500 for(int32_t j=0; j<max_num_combo_aliases; j++)
18639 {
18640 byte width,height,mask,tempcset;
18641 int32_t count;
18642 word tempword;
18643 byte tempbyte;
18644
18645
1/2
✓ Branch 0 taken 358400 times.
✗ Branch 1 not taken.
358400 if(!p_igetw(&tempword,f,true))
18646 {
18647 return qe_invalid;
18648 }
18649
18650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 358400 times.
358400 if(keepdata)
18651 {
18652 358400 combo_aliases[j].combo = tempword;
18653 358400 }
18654
18655
1/2
✓ Branch 0 taken 358400 times.
✗ Branch 1 not taken.
358400 if(!p_getc(&tempbyte,f,true))
18656 {
18657 return qe_invalid;
18658 }
18659
18660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 358400 times.
358400 if(keepdata)
18661 {
18662 358400 combo_aliases[j].cset = tempbyte;
18663 358400 }
18664
18665
1/2
✓ Branch 0 taken 358400 times.
✗ Branch 1 not taken.
358400 if(!p_getc(&width,f,true))
18666 {
18667 return qe_invalid;
18668 }
18669
18670
1/2
✓ Branch 0 taken 358400 times.
✗ Branch 1 not taken.
358400 if(!p_getc(&height,f,true))
18671 {
18672 return qe_invalid;
18673 }
18674
18675
1/2
✓ Branch 0 taken 358400 times.
✗ Branch 1 not taken.
358400 if(!p_getc(&mask,f,true))
18676 {
18677 return qe_invalid;
18678 }
18679
18680 358400 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18681
18682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 358400 times.
358400 if(keepdata)
18683 {
18684
1/2
✓ Branch 0 taken 358400 times.
✗ Branch 1 not taken.
358400 if(combo_aliases[j].combos != NULL)
18685 {
18686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 358400 times.
358400 delete[] combo_aliases[j].combos;
18687 358400 }
18688
18689
1/2
✓ Branch 0 taken 358400 times.
✗ Branch 1 not taken.
358400 if(combo_aliases[j].csets != NULL)
18690 {
18691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 358400 times.
358400 delete[] combo_aliases[j].csets;
18692 358400 }
18693
18694 358400 combo_aliases[j].width = width;
18695 358400 combo_aliases[j].height = height;
18696 358400 combo_aliases[j].layermask = mask;
18697 358400 combo_aliases[j].combos = new word[count];
18698 358400 combo_aliases[j].csets = new byte[count];
18699 358400 }
18700
18701
2/2
✓ Branch 0 taken 367133 times.
✓ Branch 1 taken 358400 times.
725533 for(int32_t k=0; k<count; k++)
18702 {
18703
1/2
✓ Branch 0 taken 367133 times.
✗ Branch 1 not taken.
367133 if(!p_igetw(&tempword,f,true))
18704 {
18705 return qe_invalid;
18706 }
18707
18708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367133 times.
367133 if(keepdata)
18709 {
18710 367133 combo_aliases[j].combos[k] = tempword;
18711 367133 }
18712 367133 }
18713
18714
2/2
✓ Branch 0 taken 367133 times.
✓ Branch 1 taken 358400 times.
725533 for(int32_t k=0; k<count; k++)
18715 {
18716
1/2
✓ Branch 0 taken 367133 times.
✗ Branch 1 not taken.
367133 if(!p_getc(&tempcset,f,true))
18717 {
18718 return qe_invalid;
18719 }
18720
18721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 367133 times.
367133 if(keepdata)
18722 {
18723 367133 combo_aliases[j].csets[k] = tempcset;
18724 367133 }
18725 367133 }
18726 358400 }
18727
18728 100 word num_combo_pools = 0;
18729
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 23 times.
100 if(sversion >= 4)
18730 {
18731
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetw(&num_combo_pools,f,true))
18732 {
18733 return qe_invalid;
18734 }
18735 23 }
18736
18737
2/2
✓ Branch 0 taken 819200 times.
✓ Branch 1 taken 100 times.
819300 for(combo_pool& pool : combo_pools)
18738 {
18739 819200 pool.clear();
18740 }
18741
18742 100 combo_pool temp_cpool;
18743
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 100 times.
163 for(word cp = 0; cp < num_combo_pools; ++cp)
18744 {
18745 63 int32_t num_combos_in_pool = 0;
18746
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
63 if(!p_igetl(&num_combos_in_pool,f,true))
18747 {
18748 return qe_invalid;
18749 }
18750
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(num_combos_in_pool < 1) continue; //nothing to read
18751
18752
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 temp_cpool.clear();
18753
18754 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18755
2/2
✓ Branch 0 taken 273 times.
✓ Branch 1 taken 63 times.
336 for(auto q = 0; q < num_combos_in_pool; ++q)
18756 {
18757
2/4
✓ Branch 0 taken 273 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 273 times.
✗ Branch 3 not taken.
273 if(!p_igetl(&cp_cid,f,true))
18758 {
18759 return qe_invalid;
18760 }
18761
2/4
✓ Branch 0 taken 273 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 273 times.
✗ Branch 3 not taken.
273 if(!p_getc(&cp_cs,f,true))
18762 {
18763 return qe_invalid;
18764 }
18765
2/4
✓ Branch 0 taken 273 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 273 times.
✗ Branch 3 not taken.
273 if(!p_igetw(&cp_quant,f,true))
18766 {
18767 return qe_invalid;
18768 }
18769
1/2
✓ Branch 0 taken 273 times.
✗ Branch 1 not taken.
273 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18770 273 }
18771
18772
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(keepdata)
18773 {
18774
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 combo_pools[cp] = temp_cpool;
18775 63 }
18776 63 }
18777
18778 100 return 0;
18779 100 }
18780
18781 109 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets, bool keepdata)
18782 {
18783 //these are here to bypass compiler warnings about unused arguments
18784
18785 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18786 //Capitalized cause it'll save you a headache. -Deedee
18787 109 start_cset=start_cset;
18788 109 max_csets=max_csets;
18789 109 word s_version=0;
18790
18791 miscQdata temp_misc;
18792 109 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18793
18794 byte temp_colordata[48];
18795 char temp_palname[PALNAMESIZE];
18796
18797 int32_t dummy;
18798 word palcycles;
18799
18800
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 105 times.
109 if(version > 0x192)
18801 {
18802 //section version info
18803
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_version,f,true))
18804 {
18805 return qe_invalid;
18806 }
18807
18808 105 FFCore.quest_format[vCSets] = s_version;
18809
18810 //al_trace("Color data version %d\n", s_version);
18811
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&dummy,f,true))
18812 {
18813 return qe_invalid;
18814 }
18815
18816 //section size
18817
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy,f,true))
18818 {
18819 return qe_invalid;
18820 }
18821 105 }
18822
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 25 times.
109 if (s_version < 5)
18823 {
18824
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
84 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18825
18826 //finally... section data
18827 84 int32_t q = 0;
18828 84 int32_t p = -15;
18829
2/2
✓ Branch 0 taken 20160 times.
✓ Branch 1 taken 84 times.
20244 for(int32_t i=0; i<oldpdTOTAL; ++i)
18830 {
18831 20160 memset(temp_colordata, 0, 48);
18832
18833
1/2
✓ Branch 0 taken 20160 times.
✗ Branch 1 not taken.
20160 if(!pfread(temp_colordata,48,f,true))
18834 {
18835 return qe_invalid;
18836 }
18837
18838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20160 times.
20160 if(keepdata==true)
18839 {
18840 20160 memcpy(&colordata[q*48], temp_colordata, 48);
18841 20160 }
18842 20160 ++q;
18843
8/8
✓ Branch 0 taken 18816 times.
✓ Branch 1 taken 1344 times.
✓ Branch 2 taken 1428 times.
✓ Branch 3 taken 17388 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 1260 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 160 times.
20160 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18844 {
18845
1/2
✓ Branch 0 taken 1420 times.
✗ Branch 1 not taken.
1420 if (s_version < 5) //Bumping up the size of level palettes
18846 {
18847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1420 times.
1420 if(keepdata==true)
18848 {
18849 1420 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18850 1420 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18851 1420 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18852 1420 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18853 1420 }
18854 1420 q+=4;
18855 1420 }
18856 else
18857 {
18858 for(int m = 0; m < 4; ++m)
18859 {
18860 memset(temp_colordata, 0, 48);
18861 if(!pfread(temp_colordata,48,f,true))
18862 {
18863 return qe_invalid;
18864 }
18865 if(keepdata==true)
18866 {
18867 memcpy(&colordata[q*48], temp_colordata, 48);
18868 }
18869 ++q;
18870 }
18871 }
18872 1420 }
18873 20160 ++p;
18874 20160 }
18875
18876
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 80 times.
84 if(RealOldVerion)
18877 {
18878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata==true)
18879 {
18880 4 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18881 4 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18882 4 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18883 4 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18884 4 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18885 4 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18886 4 }
18887 4 }
18888 else
18889 {
18890 80 memset(temp_colordata, 0, 48);
18891
18892
2/2
✓ Branch 0 taken 250640 times.
✓ Branch 1 taken 80 times.
250720 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18893 {
18894
1/2
✓ Branch 0 taken 250640 times.
✗ Branch 1 not taken.
250640 if(!pfread(temp_colordata,48,f,true))
18895 {
18896 return qe_invalid;
18897 }
18898
18899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 250640 times.
250640 if(keepdata==true)
18900 {
18901 250640 memcpy(&colordata[q*48], temp_colordata, 48);
18902 250640 }
18903 250640 ++q;
18904
7/8
✓ Branch 0 taken 250640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19280 times.
✓ Branch 3 taken 231360 times.
✓ Branch 4 taken 160 times.
✓ Branch 5 taken 19120 times.
✓ Branch 6 taken 150 times.
✓ Branch 7 taken 10 times.
250640 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18905 {
18906
1/2
✓ Branch 0 taken 19270 times.
✗ Branch 1 not taken.
19270 if (s_version < 5) //Bumping up the size of level palettes
18907 {
18908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19270 times.
19270 if(keepdata==true)
18909 {
18910 19270 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18911 19270 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18912 19270 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18913 19270 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18914 19270 }
18915 19270 q+=4;
18916 19270 }
18917 else
18918 {
18919 for(int m = 0; m < 4; ++m)
18920 {
18921 memset(temp_colordata, 0, 48);
18922 if(!pfread(temp_colordata,48,f,true))
18923 {
18924 return qe_invalid;
18925 }
18926 if(keepdata==true)
18927 {
18928 memcpy(&colordata[q*48], temp_colordata, 48);
18929 }
18930 ++q;
18931 }
18932 }
18933 19270 }
18934 250640 ++p;
18935 250640 }
18936
18937
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 75 times.
80 if(s_version < 4)
18938 {
18939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(keepdata==true)
18940 {
18941 5 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18942 5 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18943 5 }
18944 5 }
18945 else
18946 {
18947
2/2
✓ Branch 0 taken 249600 times.
✓ Branch 1 taken 75 times.
249675 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18948 {
18949
1/2
✓ Branch 0 taken 249600 times.
✗ Branch 1 not taken.
249600 if(!pfread(temp_colordata,48,f,true))
18950 {
18951 return qe_invalid;
18952 }
18953
18954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 249600 times.
249600 if(keepdata==true)
18955 {
18956 249600 memcpy(&colordata[q*48], temp_colordata, 48);
18957 249600 }
18958 249600 ++q;
18959
5/6
✓ Branch 0 taken 249600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19200 times.
✓ Branch 3 taken 230400 times.
✓ Branch 4 taken 150 times.
✓ Branch 5 taken 19050 times.
249600 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18960 {
18961
1/2
✓ Branch 0 taken 19050 times.
✗ Branch 1 not taken.
19050 if (s_version < 5) //Bumping up the size of level palettes
18962 {
18963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19050 times.
19050 if(keepdata==true)
18964 {
18965 19050 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18966 19050 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18967 19050 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18968 19050 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18969 19050 }
18970 19050 q+=4;
18971 19050 }
18972 else
18973 {
18974 for(int m = 0; m < 4; ++m)
18975 {
18976 memset(temp_colordata, 0, 48);
18977 if(!pfread(temp_colordata,48,f,true))
18978 {
18979 return qe_invalid;
18980 }
18981 if(keepdata==true)
18982 {
18983 memcpy(&colordata[q*48], temp_colordata, 48);
18984 }
18985 ++q;
18986 }
18987 }
18988 19050 }
18989 249600 ++p;
18990 249600 }
18991
18992 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18993 }
18994 }
18995 84 }
18996 else
18997 {
18998
2/2
✓ Branch 0 taken 218725 times.
✓ Branch 1 taken 25 times.
218750 for(int32_t i=0; i<pdTOTAL255; ++i)
18999 {
19000 218725 memset(temp_colordata, 0, 48);
19001
19002
1/2
✓ Branch 0 taken 218725 times.
✗ Branch 1 not taken.
218725 if(!pfread(temp_colordata,48,f,true))
19003 {
19004 return qe_invalid;
19005 }
19006
19007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 218725 times.
218725 if(keepdata==true)
19008 {
19009 218725 memcpy(&colordata[i*48], temp_colordata, 48);
19010 218725 }
19011 218725 }
19012 }
19013
19014
3/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
109 if((version < 0x192)||((version == 0x192)&&(build<76)))
19015 {
19016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata==true)
19017 {
19018 4 init_palnames();
19019 4 }
19020 4 }
19021 else
19022 {
19023 105 int32_t palnamestoread = 0;
19024
19025
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 100 times.
105 if(s_version < 3)
19026 5 palnamestoread = OLDMAXLEVELS;
19027 else
19028 100 palnamestoread = 512;
19029
19030
2/2
✓ Branch 0 taken 52480 times.
✓ Branch 1 taken 105 times.
52585 for(int32_t i=0; i<palnamestoread; ++i)
19031 {
19032 52480 memset(temp_palname, 0, PALNAMESIZE);
19033
19034
1/2
✓ Branch 0 taken 52480 times.
✗ Branch 1 not taken.
52480 if(!pfread(temp_palname,PALNAMESIZE,f,true))
19035 {
19036 return qe_invalid;
19037 }
19038
19039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52480 times.
52480 if(keepdata==true)
19040 {
19041 52480 memcpy(palnames[i], temp_palname, PALNAMESIZE);
19042 52480 }
19043 52480 }
19044
19045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(keepdata)
19046 {
19047
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 105 times.
1385 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
19048 {
19049 1280 memset(palnames[i], 0, PALNAMESIZE);
19050 1280 }
19051 105 }
19052 }
19053
19054
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 105 times.
109 if(version > 0x192)
19055 {
19056
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 105 times.
26985 for(int32_t i=0; i<256; i++)
19057 {
19058
2/2
✓ Branch 0 taken 80640 times.
✓ Branch 1 taken 26880 times.
107520 for(int32_t j=0; j<3; j++)
19059 {
19060 80640 temp_misc.cycles[i][j].first=0;
19061 80640 temp_misc.cycles[i][j].count=0;
19062 80640 temp_misc.cycles[i][j].speed=0;
19063 80640 }
19064 26880 }
19065
19066
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&palcycles,f,true))
19067 {
19068 return qe_invalid;
19069 }
19070
19071
2/2
✓ Branch 0 taken 3342 times.
✓ Branch 1 taken 105 times.
3447 for(int32_t i=0; i<palcycles; i++)
19072 {
19073
2/2
✓ Branch 0 taken 10026 times.
✓ Branch 1 taken 3342 times.
13368 for(int32_t j=0; j<3; j++)
19074 {
19075
1/2
✓ Branch 0 taken 10026 times.
✗ Branch 1 not taken.
10026 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
19076 {
19077 return qe_invalid;
19078 }
19079 10026 }
19080
19081
2/2
✓ Branch 0 taken 10026 times.
✓ Branch 1 taken 3342 times.
13368 for(int32_t j=0; j<3; j++)
19082 {
19083
1/2
✓ Branch 0 taken 10026 times.
✗ Branch 1 not taken.
10026 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
19084 {
19085 return qe_invalid;
19086 }
19087 10026 }
19088
19089
2/2
✓ Branch 0 taken 10026 times.
✓ Branch 1 taken 3342 times.
13368 for(int32_t j=0; j<3; j++)
19090 {
19091
1/2
✓ Branch 0 taken 10026 times.
✗ Branch 1 not taken.
10026 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
19092 {
19093 return qe_invalid;
19094 }
19095 10026 }
19096 3342 }
19097
19098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(keepdata==true)
19099 {
19100 105 memcpy(Misc, &temp_misc, sizeof(temp_misc));
19101 105 }
19102 105 }
19103
19104 109 return 0;
19105 109 }
19106
19107 109 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init, bool keepdata)
19108 {
19109 109 int32_t tiles_used=0;
19110 109 word section_version = 0;
19111 109 word section_cversion = 0;
19112 109 int32_t section_size= 0;
19113 109 byte *temp_tile = new byte[tilesize(tf32Bit)];
19114
19115 //Tile Expansion
19116 //if ( version >= 0x254 && build >= 41 )
19117
3/4
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
109 if (version < 0x254 && build < 41)
19118 {
19119 //al_trace("Build was < 41 when reading tiles\n");
19120 84 max_tiles = ZC250MAXTILES;
19121 84 }
19122
19123 //al_trace("Max Tiles: %d\n", max_tiles);
19124
19125
2/6
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 109 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
109 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
19126 {
19127 if(keepdata==true)
19128 {
19129 if(!init_tiles(true, Header))
19130 {
19131 al_trace("Unable to initialize tiles\n");
19132 }
19133 }
19134
19135 delete[] temp_tile;
19136 temp_tile=NULL;
19137 return 0;
19138 }
19139 else
19140 {
19141
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 105 times.
109 if(version > 0x192)
19142 {
19143 //section version info
19144
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&section_version,f,true))
19145 {
19146 delete[] temp_tile;
19147 return qe_invalid;
19148 }
19149
19150 105 FFCore.quest_format[vTiles] = section_version;
19151
19152
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&section_cversion,f,true))
19153 {
19154 delete[] temp_tile;
19155 return qe_invalid;
19156 }
19157
19158 //section size
19159
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&section_size,f,true))
19160 {
19161 delete[] temp_tile;
19162 return qe_invalid;
19163 }
19164 105 }
19165
19166 //if ( build < 41 )
19167 //{
19168 // tiles_used = ZC250MAXTILES;
19169 //}
19170
19171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(version < 0x174)
19172 {
19173 tiles_used=TILES_PER_PAGE*4;
19174 } //no expanded tile space
19175
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 105 times.
109 else if(version < 0x191)
19176 {
19177 4 tiles_used=OLDMAXTILES;
19178 4 }
19179 else
19180 {
19181 //finally... section data
19182
3/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
105 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19183 {
19184
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(!p_igetl(&tiles_used,f,true))
19185 {
19186 delete[] temp_tile;
19187 return qe_invalid;
19188 }
19189 25 }
19190 else
19191 {
19192
1/2
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
80 if(!p_igetw(&tiles_used,f,true))
19193 {
19194 delete[] temp_tile;
19195 return qe_invalid;
19196 }
19197 }
19198 }
19199
19200
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 tiles_used=zc_min(tiles_used, max_tiles);
19201
19202 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19203 //if ( version < 0x254 && build < 41 )
19204
3/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
109 if ( version < 0x254 || (version == 0x254 && build < 41) )
19205 //if ( build < 41 )
19206 {
19207
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19208 84 }
19209 else //2.55
19210 {
19211
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19212 }
19213
19214 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19215
19216 //al_trace("tiles_used = %d\n", tiles_used);
19217
19218
2/2
✓ Branch 0 taken 2490078 times.
✓ Branch 1 taken 109 times.
2490187 for(int32_t i=0; i<tiles_used; ++i)
19219 {
19220 2490078 byte format=tf4Bit;
19221 2490078 memset(temp_tile, 0, tilesize(tf32Bit));
19222
19223
3/6
✓ Branch 0 taken 172238 times.
✓ Branch 1 taken 2317840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 172238 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2490078 if((version>0x211)||((version==0x211)&&(build>4)))
19224 {
19225
1/2
✓ Branch 0 taken 2317840 times.
✗ Branch 1 not taken.
2317840 if(!p_getc(&format,f,true))
19226 {
19227 delete[] temp_tile;
19228 return qe_invalid;
19229 }
19230 2317840 }
19231
4/4
✓ Branch 0 taken 838578 times.
✓ Branch 1 taken 1651500 times.
✓ Branch 2 taken 416088 times.
✓ Branch 3 taken 422490 times.
2490078 if(section_version > 2 && !format)
19232 {
19233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 422490 times.
422490 if(keepdata)
19234 {
19235 422490 reset_tile(buf,start_tile+i,tf4Bit);
19236 422490 }
19237 422490 continue;
19238 }
19239
19240
1/2
✓ Branch 0 taken 2067588 times.
✗ Branch 1 not taken.
2067588 if(!pfread(temp_tile,tilesize(format),f,true))
19241 {
19242 delete[] temp_tile;
19243 return qe_invalid;
19244 }
19245
19246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2067588 times.
2067588 if(keepdata==true)
19247 {
19248 2067588 buf[start_tile+i].format=format;
19249
19250
1/2
✓ Branch 0 taken 2067588 times.
✗ Branch 1 not taken.
2067588 if(buf[start_tile+i].data)
19251 {
19252 2067588 free(buf[start_tile+i].data);
19253 2067588 buf[start_tile+i].data=NULL;
19254 2067588 }
19255
19256 2067588 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19257 2067588 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19258 2067588 }
19259 2067588 }
19260 }
19261
19262
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19263 {
19264 //al_trace("Writing blank tile data to new tiles for build < 41\n");
19265
2/2
✓ Branch 0 taken 12514320 times.
✓ Branch 1 taken 84 times.
12514404 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19266 {
19267
19268 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19269 12514320 reset_tile(buf,q,tf4Bit);
19270
19271
19272 /*
19273
19274 byte tempbyte;
19275 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19276 {
19277 tempbyte=buf[ZC250MAXTILES-1].data[i];
19278 buf[q].data[i] = tempbyte;
19279 }
19280 //int32_t temp = tempbyte=buf[130].data[i];
19281 //buf[q].data = buf[ZC250MAXTILES-1].data;
19282 */
19283 //reset_tile(buf,q,tf4Bit);
19284 12514320 }
19285
19286 84 }
19287
19288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(keepdata==true)
19289 {
19290
4/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
109 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19291 {
19292
2/2
✓ Branch 0 taken 4060800 times.
✓ Branch 1 taken 84 times.
4060884 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19293 {
19294 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
19295 4060800 reset_tile(buf,i,tf4Bit);
19296 4060800 }
19297 84 }
19298 else
19299 {
19300
2/2
✓ Branch 0 taken 4315302 times.
✓ Branch 1 taken 25 times.
4315327 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19301 {
19302 //al_trace("Resetting tiles for build 41+\n");
19303 4315302 reset_tile(buf,i,tf4Bit);
19304 4315302 }
19305 }
19306
19307
3/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
109 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19308 {
19309
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_bit(quest_rules,qr_BSZELDA)) //
19310 {
19311 byte tempbyte;
19312 int32_t floattile=wpnsbuf[iwSwim].tile;
19313
19314 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19315 {
19316 tempbyte=buf[23].data[i];
19317 buf[23].data[i]=buf[24].data[i];
19318 buf[24].data[i]=buf[25].data[i];
19319 buf[25].data[i]=buf[26].data[i];
19320 buf[26].data[i]=tempbyte;
19321 }
19322 //swim tiles are out of order, too, but nobody cared? -Z
19323 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19324 {
19325 tempbyte=buf[floattile+11].data[i];
19326 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19327 buf[floattile+12].data[i]=tempbyte;
19328 }
19329 }
19330 4 }
19331
19332
3/6
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
109 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19333 {
19334
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4 times.
9 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
19335 {
19336 byte tempbyte;
19337
19338
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19339 {
19340 512 tempbyte=buf[130].data[i];
19341 512 buf[130].data[i]=buf[132].data[i];
19342 512 buf[132].data[i]=tempbyte;
19343
19344 512 tempbyte=buf[131].data[i];
19345 512 buf[131].data[i]=buf[133].data[i];
19346 512 buf[133].data[i]=tempbyte;
19347 512 }
19348 4 }
19349 9 }
19350
19351 109 al_trace("Registering blank tiles\n");
19352 109 register_blank_tiles();
19353 109 }
19354
19355 //memset(temp_tile, 0, tilesize(tf32Bit));
19356
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 delete[] temp_tile;
19357 109 temp_tile=NULL;
19358 109 return 0;
19359 109 }
19360
19361 109 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/, bool keepdata)
19362 {
19363 109 byte *mf=midi_flags;
19364 int32_t dummy;
19365 word dummy2;
19366 // zcmidi_ temp_midi;
19367 int32_t tunes_to_read;
19368 109 int32_t tune_count=0;
19369 109 word section_version=0;
19370 109 zctune temp;
19371
19372
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 105 times.
109 if(Header->zelda_version < 0x193)
19373 {
19374 // mf=Header->data_flags+ZQ_MIDIS2;
19375
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19376 {
19377 4 tunes_to_read=MAXCUSTOMMIDIS192b177;
19378 4 }
19379 else
19380 {
19381 tunes_to_read=MAXCUSTOMTUNES;
19382 }
19383 4 }
19384 else
19385 {
19386 //section version info
19387
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&section_version,f,true))
19388 {
19389 return qe_invalid;
19390 }
19391
19392 105 FFCore.quest_format[vMIDIs] = section_version;
19393
19394 //al_trace("Tunes version %d\n", section_version);
19395
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&dummy2,f,true))
19396 {
19397 return qe_invalid;
19398 }
19399
19400 //section size
19401
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy,f,true))
19402 {
19403 return qe_invalid;
19404 }
19405
19406 //finally... section data
19407
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!pfread(midi_flags,sizeof(midi_flags),f,true))
19408 {
19409 return qe_invalid;
19410 }
19411
19412 105 tunes_to_read=MAXCUSTOMTUNES;
19413 }
19414
19415
2/2
✓ Branch 0 taken 27468 times.
✓ Branch 1 taken 109 times.
27577 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19416 {
19417
2/2
✓ Branch 0 taken 25629 times.
✓ Branch 1 taken 1839 times.
27468 if(get_bit(mf, i))
19418 {
19419 1839 ++tune_count;
19420 1839 }
19421 27468 }
19422
19423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(keepdata==true)
19424 {
19425 109 reset_tunes(tunes); //reset_midis(midis);
19426 109 }
19427
19428
2/2
✓ Branch 0 taken 26588 times.
✓ Branch 1 taken 109 times.
26697 for(int32_t i=0; i<tunes_to_read; i++)
19429 {
19430 26588 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19431
19432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26588 times.
26588 if(keepdata==true)
19433 {
19434 26588 tunes[i].reset(); // reset_midi(midis+i);
19435 26588 }
19436
19437
2/2
✓ Branch 0 taken 24749 times.
✓ Branch 1 taken 1839 times.
26588 if(get_bit(mf,i))
19438 {
19439
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 1542 times.
1839 if(section_version < 4)
19440 {
19441
1/2
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
297 if(!pfread(&temp.title,sizeof(char)*20,f,true))
19442 {
19443 return qe_invalid;
19444 }
19445 297 }
19446 else
19447 {
19448
1/2
✓ Branch 0 taken 1542 times.
✗ Branch 1 not taken.
1542 if(!pfread(&temp.title,sizeof(temp.title),f,true))
19449 {
19450 return qe_invalid;
19451 }
19452 }
19453
19454
1/2
✓ Branch 0 taken 1839 times.
✗ Branch 1 not taken.
1839 if(!p_igetl(&temp.start,f,true))
19455 {
19456 return qe_invalid;
19457 }
19458
19459
1/2
✓ Branch 0 taken 1839 times.
✗ Branch 1 not taken.
1839 if(!p_igetl(&temp.loop_start,f,true))
19460 {
19461 return qe_invalid;
19462 }
19463
19464
1/2
✓ Branch 0 taken 1839 times.
✗ Branch 1 not taken.
1839 if(!p_igetl(&temp.loop_end,f,true))
19465 {
19466 return qe_invalid;
19467 }
19468
19469
1/2
✓ Branch 0 taken 1839 times.
✗ Branch 1 not taken.
1839 if(!p_igetw(&temp.loop,f,true))
19470 {
19471 return qe_invalid;
19472 }
19473
19474
1/2
✓ Branch 0 taken 1839 times.
✗ Branch 1 not taken.
1839 if(!p_igetw(&temp.volume,f,true))
19475 {
19476 return qe_invalid;
19477 }
19478
19479
2/2
✓ Branch 0 taken 1761 times.
✓ Branch 1 taken 78 times.
1839 if(Header->zelda_version < 0x193)
19480 {
19481
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 if(!p_igetl(&dummy,f,true))
19482 {
19483 return qe_invalid;
19484 }
19485 78 }
19486
19487
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 1542 times.
1839 if(section_version >= 3)
19488 {
19489
1/2
✓ Branch 0 taken 1542 times.
✗ Branch 1 not taken.
1542 if(!pfread(&temp.flags,sizeof(temp.flags),f,true))
19490 {
19491 return qe_invalid;
19492 }
19493 1542 }
19494
19495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1839 times.
1839 if(keepdata==true)
19496 {
19497 1839 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19498 1839 }
19499
19500
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 1542 times.
1839 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19501 {
19502 // old format - a midi is a midi
19503
2/4
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 297 times.
✗ Branch 3 not taken.
297 if(((keepdata==true?tunes[i].data:temp.data)=read_midi(f, true))==NULL)
19504 {
19505 return qe_invalid;
19506 }
19507
19508 //yes you can do this. Isn't the ? operator awesome? :)
19509
1/2
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
297 (keepdata ? tunes[i] : temp).format = MFORMAT_MIDI;
19510 297 }
19511 else
19512 {
19513 // 'midi' could be midi or nes, gb, ... music
19514
2/4
✓ Branch 0 taken 1542 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1542 times.
✗ Branch 3 not taken.
1542 if(!pfread(&(keepdata ? tunes[i] : temp).format,sizeof((keepdata ? tunes[i] : temp).format),f,true))
19515 {
19516 return qe_invalid;
19517 }
19518
19519
1/2
✓ Branch 0 taken 1542 times.
✗ Branch 1 not taken.
1542 zctune *ptr = (keepdata==true)?&(tunes[i]):&temp;
19520
19521
1/2
✓ Branch 0 taken 1542 times.
✗ Branch 1 not taken.
1542 switch(temp.format)
19522 {
19523 case MFORMAT_MIDI:
19524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1542 times.
1542 if((ptr->data=read_midi(f, true))==NULL)
19525 {
19526 return qe_invalid;
19527 }
19528
19529 1542 break;
19530
19531 default:
19532 return qe_invalid;
19533 break;
19534 }
19535 }
19536 1839 }
19537 26588 }
19538
19539 109 return 0;
19540 109 }
19541
19542 109 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header, bool keepdata)
19543 {
19544 int32_t dummy;
19545 ZCHEATS tempzcheats;
19546 109 char temp_use_cheats=1;
19547 109 memset(&tempzcheats, 0, sizeof(tempzcheats));
19548 109 word s_version = 0;
19549
19550
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 105 times.
109 if(Header->zelda_version > 0x192)
19551 {
19552 //section version info
19553
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&s_version,f,true))
19554 {
19555 return qe_invalid;
19556 }
19557
19558 105 FFCore.quest_format[vCheats] = s_version;
19559 //al_trace("Cheats version %d\n", dummy);
19560
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetw(&dummy,f,true))
19561 {
19562 return qe_invalid;
19563 }
19564
19565 //section size
19566
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_igetl(&dummy,f,true))
19567 {
19568 return qe_invalid;
19569 }
19570
19571 //finally... section data
19572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(!p_getc(&temp_use_cheats,f,true))
19573 {
19574 return qe_invalid;
19575 }
19576 105 }
19577
19578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(Header->data_flags[ZQ_CHEATS2])
19579 {
19580
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if(!p_igetl(&tempzcheats.flags,f,true))
19581 {
19582 return qe_invalid;
19583 }
19584
19585
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes), f,true))
19586 {
19587 return qe_invalid;
19588 }
19589 109 }
19590
19591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(keepdata==true)
19592 {
19593 109 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19594 109 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19595 109 }
19596
19597 109 return 0;
19598 109 }
19599
19600 271 int32_t readinitdata(PACKFILE *f, zquestheader *Header, bool keepdata)
19601 {
19602 int32_t dummy;
19603 271 word s_version=0, s_cversion=0;
19604 byte padding;
19605 word tempw;
19606
19607 271 zinitdata temp_zinit;
19608
19609 // Legacy item properties (now integrated into itemdata)
19610 byte sword_hearts[4];
19611 byte beam_hearts[4];
19612 271 byte beam_percent=0;
19613 word beam_power[4];
19614 271 byte hookshot_length=99;
19615 271 byte hookshot_links=100;
19616 271 byte longshot_length=99;
19617 271 byte longshot_links=100;
19618 271 byte moving_fairy_hearts=3;
19619 271 byte moving_fairy_heart_percent=0;
19620 271 byte stationary_fairy_hearts=3;
19621 271 byte stationary_fairy_heart_percent=0;
19622 271 byte moving_fairy_magic=0;
19623 271 byte moving_fairy_magic_percent=0;
19624 271 byte stationary_fairy_magic=0;
19625 271 byte stationary_fairy_magic_percent=0;
19626 271 byte blue_potion_hearts=100;
19627 271 byte blue_potion_heart_percent=1;
19628 271 byte red_potion_hearts=100;
19629 271 byte red_potion_heart_percent=1;
19630 271 byte blue_potion_magic=100;
19631 271 byte blue_potion_magic_percent=1;
19632 271 byte red_potion_magic=100;
19633 271 byte red_potion_magic_percent=1;
19634
19635
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 162 times.
271 temp_zinit.subscreen_style=get_bit(quest_rules,qr_COOLSCROLL)?1:0;
19636
19637
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
109 if(Header->zelda_version > 0x192)
19638 {
19639 //section version info
19640
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&s_version,f,true))
19641 {
19642 return qe_invalid;
19643 }
19644
19645 105 FFCore.quest_format[vInitData] = s_version;
19646
19647 //al_trace("Init data version %d\n", s_version);
19648
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&s_cversion,f,true))
19649 {
19650 return qe_invalid;
19651 }
19652
19653 //section size
19654
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetl(&dummy,f,true))
19655 {
19656 return qe_invalid;
19657 }
19658 105 }
19659
19660 /* HIGHLY UNORTHODOX UPDATING THING, by L
19661 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19662 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19663 * changing from 13 to 14.
19664 */
19665
3/4
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 9 times.
109 if(keepdata && s_version < 14)
19666 9 fixpolsvoice=true;
19667
19668 /* End highly unorthodox updating thing */
19669
19670
5/6
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 26 times.
109 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19671 26 temp_zinit.jump_hero_layer_threshold=0;
19672
19673
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 100 times.
109 if(s_version >= 10)
19674 {
19675 char temp;
19676
19677 //new-style items
19678
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 100 times.
25700 for(int32_t j=0; j<256; j++)
19679 {
19680
2/4
✓ Branch 0 taken 25600 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25600 times.
25600 if(!p_getc(&temp,f,true))
19681 return qe_invalid;
19682
19683 25600 temp_zinit.items[j] = (temp != 0);
19684 25600 }
19685 100 }
19686
19687
5/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 57 times.
✓ Branch 5 taken 57 times.
109 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19688 {
19689 char temp;
19690
19691 //finally... section data
19692
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 57 times.
✓ Branch 3 taken 57 times.
162 if((Header->zelda_version > 0x192)||
19693 //new only
19694 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19695 {
19696 //OLD-style items... sigh
19697
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 100 times.
105 if(s_version < 10)
19698 {
19699
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19700 {
19701 return qe_invalid;
19702 }
19703
19704 5 temp_zinit.items[iRaft]=(temp != 0);
19705
19706
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19707 {
19708 return qe_invalid;
19709 }
19710
19711 5 temp_zinit.items[iLadder]=(temp != 0);
19712
19713
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19714 {
19715 return qe_invalid;
19716 }
19717
19718 5 temp_zinit.items[iBook]=(temp != 0);
19719
19720
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19721 {
19722 return qe_invalid;
19723 }
19724
19725 5 temp_zinit.items[iMKey]=(temp!=0);
19726
19727
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19728 {
19729 return qe_invalid;
19730 }
19731
19732 5 temp_zinit.items[iFlippers]=(temp != 0);
19733
19734
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19735 {
19736 return qe_invalid;
19737 }
19738
19739 5 temp_zinit.items[iBoots]=(temp!=0);
19740 5 }
19741 105 }
19742
19743
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 155 times.
162 if(s_version < 10)
19744 {
19745 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19746
19747
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempring,f,true))
19748 {
19749 return qe_invalid;
19750 }
19751
19752
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempsword,f,true))
19753 {
19754 return qe_invalid;
19755 }
19756
19757
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempshield,f,true))
19758 {
19759 return qe_invalid;
19760 }
19761
19762
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempwallet,f,true))
19763 {
19764 return qe_invalid;
19765 }
19766
19767
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempbracelet,f,true))
19768 {
19769 return qe_invalid;
19770 }
19771
19772
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempamulet,f,true))
19773 {
19774 return qe_invalid;
19775 }
19776
19777
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempbow,f,true))
19778 {
19779 return qe_invalid;
19780 }
19781
19782 //old only
19783
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version == 0x192)&&(Header->build<174))
19784 {
19785 tempring=(tempring)?(1<<(tempring-1)):0;
19786 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19787 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19788 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19789 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19790 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19791 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19792 }
19793
19794 //rings start at level 2... wtf
19795 //account for this -DD
19796 5 tempring <<= 1;
19797
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19798
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19799
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19800
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19801 //bracelet ALSO starts at level 2 :-( -DD
19802 5 tempbracelet<<=1;
19803
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19804
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19805
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19806
19807 //new only
19808
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version == 0x192)&&(Header->build>173))
19809 {
19810 for(int32_t q=0; q<32; q++)
19811 {
19812 if(!p_getc(&padding,f,true))
19813 {
19814 return qe_invalid;
19815 }
19816 }
19817 }
19818
19819 char tempcandle, tempboomerang, temparrow, tempwhistle;
19820
19821
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempcandle,f,true))
19822 {
19823 return qe_invalid;
19824 }
19825
19826
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempboomerang,f,true))
19827 {
19828 return qe_invalid;
19829 }
19830
19831
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temparrow,f,true))
19832 {
19833 return qe_invalid;
19834 }
19835
19836
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19837 {
19838 return qe_invalid;
19839 }
19840
19841
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19842
19843
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempwhistle,f,true))
19844 {
19845 return qe_invalid;
19846 }
19847
19848 //old only
19849
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version == 0x192)&&(Header->build<174))
19850 {
19851 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19852 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19853 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19854 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19855 }
19856
19857
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19858
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19859
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19860
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19861 //What about the potion...?
19862
19863 5 }
19864
19865
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 80 times.
160 if(s_version < 29)
19866 {
19867 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19868 //to jab out my eye...
19869
2/4
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
80 if(!p_getc(&padding,f,true))
19870 return qe_invalid;
19871 80 temp_zinit.bombs = padding;
19872
19873
2/4
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
80 if(!p_getc(&padding,f,true))
19874 return qe_invalid;
19875 80 temp_zinit.super_bombs = padding;
19876 80 }
19877
19878 //Back to more OLD item code
19879
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
160 if(s_version < 10)
19880 {
19881
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version > 0x192)||
19882 //new only
19883 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19884 {
19885
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19886 {
19887 return qe_invalid;
19888 }
19889
19890
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19891
19892
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19893 {
19894 return qe_invalid;
19895 }
19896
19897
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19898
19899
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19900 {
19901 return qe_invalid;
19902 }
19903
19904
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19905
19906
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19907 {
19908 return qe_invalid;
19909 }
19910
19911
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19912
19913
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19914 {
19915 return qe_invalid;
19916 }
19917
19918
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19919
19920
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19921 {
19922 return qe_invalid;
19923 }
19924
19925
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19926
19927
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19928 {
19929 return qe_invalid;
19930 }
19931
19932
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19933
19934
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19935 {
19936 return qe_invalid;
19937 }
19938
19939
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19940
19941
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19942 {
19943 return qe_invalid;
19944 }
19945
19946
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19947
19948
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19949 {
19950 return qe_invalid;
19951 }
19952
19953
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(Header->zelda_version == 0x192)
19954 {
19955 for(int32_t q=0; q<32; q++)
19956 {
19957 if(!p_getc(&padding,f,true))
19958 {
19959 return qe_invalid;
19960 }
19961 }
19962 }
19963 5 }
19964 5 }
19965
19966 //old only
19967
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
10 if((Header->zelda_version == 0x192)&&(Header->build<174))
19968 {
19969 byte equipment, items; //bit flags
19970
19971 if(!p_getc(&equipment,f,true))
19972 {
19973 return qe_invalid;
19974 }
19975
19976 temp_zinit.items[iRaft]=(get_bit(&equipment, idE_RAFT)!=0);
19977 temp_zinit.items[iLadder]=(get_bit(&equipment, idE_LADDER)!=0);
19978 temp_zinit.items[iBook]=(get_bit(&equipment, idE_BOOK)!=0);
19979 temp_zinit.items[iMKey]=(get_bit(&equipment, idE_KEY)!=0);
19980 temp_zinit.items[iFlippers]=(get_bit(&equipment, idE_FLIPPERS)!=0);
19981 temp_zinit.items[iBoots]=(get_bit(&equipment, idE_BOOTS)!=0);
19982
19983
19984 if(!p_getc(&items,f,true))
19985 {
19986 return qe_invalid;
19987 }
19988
19989 temp_zinit.items[iWand]=(get_bit(&items, idI_WAND)!=0);
19990 temp_zinit.items[iLetter]=(get_bit(&items, idI_LETTER)!=0);
19991 temp_zinit.items[iLens]=(get_bit(&items, idI_LENS)!=0);
19992 temp_zinit.items[iHookshot]=(get_bit(&items, idI_HOOKSHOT)!=0);
19993 temp_zinit.items[iBait]=(get_bit(&items, idI_BAIT)!=0);
19994 temp_zinit.items[iHammer]=(get_bit(&items, idI_HAMMER)!=0);
19995 }
19996
19997 if(!p_getc(&temp_zinit.hc,f,true))
19998 {
19999 return qe_invalid;
20000 }
20001
20002
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 100 times.
105 if(s_version < 14)
20003 {
20004 byte temphp;
20005
20006
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temphp,f,true))
20007 {
20008 return qe_invalid;
20009 }
20010
20011 5 temp_zinit.start_heart=temphp;
20012
20013
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temphp,f,true))
20014 {
20015 return qe_invalid;
20016 }
20017
20018 5 temp_zinit.cont_heart=temphp;
20019 5 }
20020 else
20021 {
20022
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_igetw(&temp_zinit.start_heart,f,true))
20023 {
20024 return qe_invalid;
20025 }
20026
20027
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_igetw(&temp_zinit.cont_heart,f,true))
20028 {
20029 return qe_invalid;
20030 }
20031 }
20032
20033
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.hcp,f,true))
20034 {
20035 return qe_invalid;
20036 }
20037
20038
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 5 times.
105 if(s_version >= 14)
20039 {
20040
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_getc(&temp_zinit.hcp_per_hc,f,true))
20041 {
20042 return qe_invalid;
20043 }
20044
20045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(s_version<16) // July 2007
20046 {
20047 if(get_bit(quest_rules,qr_BRANGPICKUP+1))
20048 temp_zinit.hcp_per_hc = 0xFF;
20049
20050 //Dispose of legacy rule
20051 set_bit(quest_rules,qr_BRANGPICKUP+1, 0);
20052 }
20053 100 }
20054
20055
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 25 times.
105 if(s_version < 29)
20056 {
20057
2/4
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
80 if(!p_getc(&padding,f,true))
20058 return qe_invalid;
20059 80 temp_zinit.max_bombs = padding;
20060 80 }
20061
20062
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.keys,f,true))
20063 {
20064 return qe_invalid;
20065 }
20066
20067
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetw(&temp_zinit.rupies,f,true))
20068 {
20069 return qe_invalid;
20070 }
20071
20072
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.triforce,f,true))
20073 {
20074 return qe_invalid;
20075 }
20076
20077
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 100 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
105 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20078 {
20079
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 100 times.
6500 for(int32_t i=0; i<64; i++)
20080 {
20081
2/4
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6400 times.
6400 if(!p_getc(&temp_zinit.map[i],f,true))
20082 {
20083 return qe_invalid;
20084 }
20085 6400 }
20086
20087
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 100 times.
6500 for(int32_t i=0; i<64; i++)
20088 {
20089
2/4
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6400 times.
6400 if(!p_getc(&temp_zinit.compass[i],f,true))
20090 {
20091 return qe_invalid;
20092 }
20093 6400 }
20094 100 }
20095 else
20096 {
20097
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 5 times.
165 for(int32_t i=0; i<32; i++)
20098 {
20099
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
160 if(!p_getc(&temp_zinit.map[i],f,true))
20100 {
20101 return qe_invalid;
20102 }
20103 160 }
20104
20105
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 5 times.
165 for(int32_t i=0; i<32; i++)
20106 {
20107
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
160 if(!p_getc(&temp_zinit.compass[i],f,true))
20108 {
20109 return qe_invalid;
20110 }
20111 160 }
20112 }
20113
20114
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
105 if((Header->zelda_version > 0x192)||
20115 //new only
20116 ((Header->zelda_version == 0x192)&&(Header->build>173)))
20117 {
20118
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 100 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
105 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
20119 {
20120
2/2
✓ Branch 0 taken 6400 times.
✓ Branch 1 taken 100 times.
6500 for(int32_t i=0; i<64; i++)
20121 {
20122
2/4
✓ Branch 0 taken 6400 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6400 times.
6400 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20123 {
20124 return qe_invalid;
20125 }
20126 6400 }
20127 100 }
20128 else
20129 {
20130
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 5 times.
165 for(int32_t i=0; i<32; i++)
20131 {
20132
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20133 {
20134 return qe_invalid;
20135 }
20136 160 }
20137 }
20138 105 }
20139
20140
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 1680 times.
1785 for(int32_t i=0; i<16; i++)
20141 {
20142
2/4
✓ Branch 0 taken 1680 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1680 times.
1680 if(!p_getc(&temp_zinit.misc[i],f,true))
20143 {
20144 return qe_invalid;
20145 }
20146 1680 }
20147
20148
4/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 5 times.
125 if(s_version < 15) for(int32_t i=0; i<4; i++)
20149 {
20150
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 if(!p_getc(&sword_hearts[i],f,true))
20151 {
20152 return qe_invalid;
20153 }
20154 25 }
20155
20156
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.last_map,f,true))
20157 {
20158 return qe_invalid;
20159 }
20160
20161
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.last_screen,f,true))
20162 {
20163 return qe_invalid;
20164 }
20165
20166
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 100 times.
105 if(s_version < 14)
20167 {
20168 byte tempmp;
20169
20170
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempmp,f,true))
20171 {
20172 return qe_invalid;
20173 }
20174
20175 5 temp_zinit.max_magic=tempmp;
20176
20177
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempmp,f,true))
20178 {
20179 return qe_invalid;
20180 }
20181
20182 5 temp_zinit.magic=tempmp;
20183 5 }
20184 else
20185 {
20186
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_igetw(&temp_zinit.max_magic,f,true))
20187 {
20188 return qe_invalid;
20189 }
20190
20191
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_igetw(&temp_zinit.magic,f,true))
20192 {
20193 return qe_invalid;
20194 }
20195 }
20196
20197
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 5 times.
105 if(s_version < 15)
20198 {
20199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(s_version < 12)
20200 {
20201 5 temp_zinit.max_magic*=32;
20202 5 temp_zinit.magic*=32;
20203 5 }
20204
20205
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 20 times.
25 for(int32_t i=0; i<4; i++)
20206 {
20207
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 if(!p_getc(&beam_hearts[i],f,true))
20208 {
20209 return qe_invalid;
20210 }
20211 20 }
20212
20213
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&beam_percent,f,true))
20214 {
20215 return qe_invalid;
20216 }
20217 5 }
20218 else
20219 {
20220
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_getc(&temp_zinit.bomb_ratio,f,true))
20221 {
20222 return qe_invalid;
20223 }
20224 }
20225
20226
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 5 times.
105 if(s_version < 15)
20227 {
20228 byte tempbp;
20229
20230
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 20 times.
25 for(int32_t i=0; i<4; i++)
20231 {
20232
3/8
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
20 if(!(s_version < 14 ? p_getc(&tempbp,f,true) : p_igetw(&tempbp,f,true)))
20233 {
20234 return qe_invalid;
20235 }
20236
20237 20 beam_power[i]=tempbp;
20238 20 }
20239
20240
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&hookshot_links,f,true))
20241 {
20242 return qe_invalid;
20243 }
20244
20245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(s_version>6)
20246 {
20247 if(!p_getc(&hookshot_length,f,true))
20248 {
20249 return qe_invalid;
20250 }
20251
20252 if(!p_getc(&longshot_links,f,true))
20253 {
20254 return qe_invalid;
20255 }
20256
20257 if(!p_getc(&longshot_length,f,true))
20258 {
20259 return qe_invalid;
20260 }
20261 }
20262 5 }
20263
20264
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.msg_more_x,f,true))
20265 {
20266 return qe_invalid;
20267 }
20268
20269
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.msg_more_y,f,true))
20270 {
20271 return qe_invalid;
20272 }
20273
20274
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.subscreen,f,true))
20275 {
20276 return qe_invalid;
20277 }
20278
20279 //old only
20280
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
105 if((Header->zelda_version == 0x192)&&(Header->build<174))
20281 {
20282 for(int32_t i=0; i<32; i++)
20283 {
20284 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20285 {
20286 return qe_invalid;
20287 }
20288 }
20289 }
20290
20291
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
105 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20292 {
20293
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 100 times.
105 if(s_version <= 10)
20294 {
20295 byte tempbyte;
20296
20297
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempbyte,f,true))
20298 {
20299 return qe_invalid;
20300 }
20301
20302 5 temp_zinit.start_dmap = (word)tempbyte;
20303 5 }
20304 else
20305 {
20306
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_igetw(&temp_zinit.start_dmap,f,true))
20307 {
20308 return qe_invalid;
20309 }
20310 }
20311
20312
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getc(&temp_zinit.heroAnimationStyle,f,true))
20313 {
20314 return qe_invalid;
20315 }
20316 105 }
20317
20318
4/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 25 times.
105 if(s_version>1 && s_version < 29)
20319 {
20320
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if(!p_getc(&padding,f,true))
20321 return qe_invalid;
20322 75 temp_zinit.arrows = padding;
20323
20324
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 if(!p_getc(&padding,f,true))
20325 return qe_invalid;
20326 75 temp_zinit.max_arrows = padding;
20327 75 }
20328
20329
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 100 times.
105 if(s_version>2)
20330 {
20331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(s_version <= 10)
20332 {
20333 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20334 {
20335 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20336 {
20337 return qe_invalid;
20338 }
20339 }
20340 }
20341 else
20342 {
20343
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 100 times.
51300 for(int32_t i=0; i<MAXLEVELS; i++)
20344 {
20345
2/4
✓ Branch 0 taken 51200 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51200 times.
✗ Branch 3 not taken.
51200 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20346 {
20347 return qe_invalid;
20348 }
20349 51200 }
20350 }
20351 100 }
20352
20353
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 5 times.
105 if(s_version>3)
20354 {
20355
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_igetw(&temp_zinit.ss_grid_x,f,true))
20356 {
20357 return qe_invalid;
20358 }
20359
20360
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_igetw(&temp_zinit.ss_grid_y,f,true))
20361 {
20362 return qe_invalid;
20363 }
20364
20365
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_igetw(&temp_zinit.ss_grid_xofs,f,true))
20366 {
20367 return qe_invalid;
20368 }
20369
20370
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_igetw(&temp_zinit.ss_grid_yofs,f,true))
20371 {
20372 return qe_invalid;
20373 }
20374
20375
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_igetw(&temp_zinit.ss_grid_color,f,true))
20376 {
20377 return qe_invalid;
20378 }
20379
20380
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f,true))
20381 {
20382 return qe_invalid;
20383 }
20384
20385
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f,true))
20386 {
20387 return qe_invalid;
20388 }
20389
20390
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_igetw(&temp_zinit.ss_flags,f,true))
20391 {
20392 return qe_invalid;
20393 }
20394
20395
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20396
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20397 100 }
20398
20399
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
105 if(s_version>4 && s_version<15)
20400 {
20401 if(!p_getc(&moving_fairy_hearts,f,true))
20402 {
20403 return qe_invalid;
20404 }
20405
20406 if(!p_getc(&moving_fairy_heart_percent,f,true))
20407 {
20408 return qe_invalid;
20409 }
20410 }
20411
20412
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
105 if(s_version>5 && s_version < 10)
20413 {
20414 if(!p_getc(&temp,f,true))
20415 {
20416 return qe_invalid;
20417 }
20418
20419 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20420 }
20421
20422
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
105 if(s_version>6 && s_version<15)
20423 {
20424 if(!p_getc(&stationary_fairy_hearts,f,true))
20425 {
20426 return qe_invalid;
20427 }
20428
20429 if(!p_getc(&stationary_fairy_heart_percent,f,true))
20430 {
20431 return qe_invalid;
20432 }
20433
20434 if(!p_getc(&moving_fairy_magic,f,true))
20435 {
20436 return qe_invalid;
20437 }
20438
20439 if(!p_getc(&moving_fairy_magic_percent,f,true))
20440 {
20441 return qe_invalid;
20442 }
20443
20444 if(!p_getc(&stationary_fairy_magic,f,true))
20445 {
20446 return qe_invalid;
20447 }
20448
20449 if(!p_getc(&stationary_fairy_magic_percent,f,true))
20450 {
20451 return qe_invalid;
20452 }
20453
20454 if(!p_getc(&blue_potion_hearts,f,true))
20455 {
20456 return qe_invalid;
20457 }
20458
20459 if(!p_getc(&blue_potion_heart_percent,f,true))
20460 {
20461 return qe_invalid;
20462 }
20463
20464 if(!p_getc(&red_potion_hearts,f,true))
20465 {
20466 return qe_invalid;
20467 }
20468
20469 if(!p_getc(&red_potion_heart_percent,f,true))
20470 {
20471 return qe_invalid;
20472 }
20473
20474 if(!p_getc(&blue_potion_magic,f,true))
20475 {
20476 return qe_invalid;
20477 }
20478
20479 if(!p_getc(&blue_potion_magic_percent,f,true))
20480 {
20481 return qe_invalid;
20482 }
20483
20484 if(!p_getc(&red_potion_magic,f,true))
20485 {
20486 return qe_invalid;
20487 }
20488
20489 if(!p_getc(&red_potion_magic_percent,f,true))
20490 {
20491 return qe_invalid;
20492 }
20493 }
20494
20495
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 5 times.
105 if(s_version>6)
20496 {
20497
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_getc(&temp_zinit.subscreen_style,f,true))
20498 {
20499 return qe_invalid;
20500 }
20501 100 }
20502
20503
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 5 times.
105 if(s_version>7)
20504 {
20505
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_getc(&temp_zinit.usecustomsfx,f,true))
20506 {
20507 return qe_invalid;
20508 }
20509 100 }
20510
20511
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 5 times.
105 if(s_version>8)
20512 {
20513
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_igetw(&temp_zinit.max_rupees,f,true))
20514 {
20515 return qe_invalid;
20516 }
20517
20518
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_igetw(&temp_zinit.max_keys,f,true))
20519 {
20520 return qe_invalid;
20521 }
20522 100 }
20523
20524
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 5 times.
105 if(s_version>16)
20525 {
20526
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_getc(&temp_zinit.gravity,f,true))
20527 {
20528 return qe_invalid;
20529 }
20530
20531
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_igetw(&temp_zinit.terminalv,f,true))
20532 {
20533 return qe_invalid;
20534 }
20535
20536
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_getc(&temp_zinit.msg_speed,f,true))
20537 {
20538 return qe_invalid;
20539 }
20540
20541
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_getc(&temp_zinit.transition_type,f,true))
20542 {
20543 return qe_invalid;
20544 }
20545
20546
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f,true))
20547 {
20548 return qe_invalid;
20549 }
20550 100 }
20551
4/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5 times.
5 else if(replay_is_replaying() && replay_get_version() < 13)
20552 5 temp_zinit.msg_speed = 0;
20553
20554
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 5 times.
105 if(s_version>17)
20555 {
20556
2/4
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
100 if(!p_getc(&temp_zinit.msg_more_is_offset,f,true))
20557 {
20558 return qe_invalid;
20559 }
20560 100 }
20561
20562 //expaned init data for larger values in 2.55
20563
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 80 times.
105 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20564 {
20565
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_igetw(&temp_zinit.bombs,f,true))
20566 {
20567 return qe_invalid;
20568 }
20569
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_igetw(&temp_zinit.super_bombs,f,true))
20570 {
20571 return qe_invalid;
20572 }
20573
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_igetw(&temp_zinit.max_bombs,f,true))
20574 {
20575 return qe_invalid;
20576 }
20577
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_igetw(&temp_zinit.max_sbombs,f,true))
20578 {
20579 return qe_invalid;
20580 }
20581
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_igetw(&temp_zinit.arrows,f,true))
20582 {
20583 return qe_invalid;
20584 }
20585
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_igetw(&temp_zinit.max_arrows,f,true))
20586 {
20587 return qe_invalid;
20588 }
20589
20590 25 }
20591
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 80 times.
105 if ( s_version >= 20 )
20592 {
20593
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_igetw(&temp_zinit.heroStep,f,true))
20594 {
20595 return qe_invalid;
20596 }
20597 25 }
20598 else
20599 {
20600 80 temp_zinit.heroStep = 150; //1.5 pixels per frame
20601 }
20602
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 80 times.
105 if ( s_version >= 21 )
20603 {
20604
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_igetw(&temp_zinit.subscrSpeed,f,true))
20605 {
20606 return qe_invalid;
20607 }
20608 25 }
20609 else
20610 {
20611 80 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20612 }
20613 //old only
20614
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
105 if((Header->zelda_version == 0x192)&&(Header->build<174))
20615 {
20616 byte items2;
20617
20618 if(!p_getc(&items2,f,true))
20619 {
20620 return qe_invalid;
20621 }
20622
20623 temp_zinit.items[iDivineFire]=(get_bit(&items2, idI_DFIRE)!=0);
20624 temp_zinit.items[iDivineEscape]=(get_bit(&items2, idI_FWIND)!=0);
20625 temp_zinit.items[iDivineProtection]=(get_bit(&items2, idI_NLOVE)!=0);
20626 }
20627
20628
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(Header->zelda_version < 0x193)
20629 {
20630 for(int32_t q=0; q<96; q++)
20631 {
20632 if(!p_getc(&padding,f,true))
20633 {
20634 return qe_invalid;
20635 }
20636 }
20637
20638 //new only
20639 if((Header->zelda_version == 0x192)&&(Header->build>173))
20640 {
20641 if(!p_getc(&padding,f,true))
20642 {
20643 return qe_invalid;
20644 }
20645
20646 if(!p_getc(&padding,f,true))
20647 {
20648 return qe_invalid;
20649 }
20650 }
20651 }
20652 105 }
20653
20654
3/6
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
166 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20655 {
20656 //temp_zinit.shield=i_smallshield;
20657
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 57 times.
66 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20658
20659
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(sshieldid != -1)
20660 9 temp_zinit.items[sshieldid] = true;
20661 9 }
20662
20663
3/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
109 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20664 {
20665 4 temp_zinit.hc=3;
20666 4 temp_zinit.start_heart=3;
20667 4 temp_zinit.cont_heart=3;
20668 4 temp_zinit.max_bombs=8;
20669 4 }
20670
20671
3/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
109 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20672 {
20673 4 sword_hearts[0]=0;
20674 4 sword_hearts[1]=5;
20675 4 sword_hearts[2]=12;
20676 4 sword_hearts[3]=21;
20677 4 }
20678
20679
3/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
109 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20680 {
20681 4 temp_zinit.last_map=0;
20682 4 temp_zinit.last_screen=0;
20683 4 }
20684
20685
3/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
109 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20686 {
20687 4 temp_zinit.max_magic=0;
20688 4 temp_zinit.magic=0;
20689
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20690 4 }
20691
20692
3/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
109 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20693 {
20694
20695
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t x=0; x<4; x++)
20696 {
20697 16 beam_hearts[x]=100;
20698 16 }
20699
20700
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<idBP_MAX; i++)
20701 {
20702
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 set_bit(&beam_percent,i,!get_bit(quest_rules,qr_LENSHINTS+i));
20703
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 set_bit(quest_rules,qr_LENSHINTS+i,0);
20704 16 }
20705
20706
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
20 for(int32_t x=0; x<4; x++)
20707 {
20708
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 beam_power[x]=get_bit(quest_rules,qr_HIDECARRIEDITEMS)?50:100;
20709 16 }
20710
20711
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(quest_rules,qr_HIDECARRIEDITEMS,0);
20712 4 hookshot_links=100;
20713 4 temp_zinit.msg_more_x=224;
20714 4 temp_zinit.msg_more_y=64;
20715 4 }
20716
20717 // Okay, let's put these legacy values into itemsbuf.
20718
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
109 if(s_version < 15)
20719
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2304 times.
2313 for(int32_t i=0; i<MAXITEMS; i++)
20720 {
20721
11/11
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 9 times.
✓ Branch 8 taken 2214 times.
✓ Branch 9 taken 9 times.
✓ Branch 10 taken 9 times.
2304 switch(i)
20722 {
20723 case iFairyStill:
20724 9 itemsbuf[i].misc1 = stationary_fairy_hearts;
20725 9 itemsbuf[i].misc2 = stationary_fairy_magic;
20726 9 itemsbuf[i].misc3 = 0;
20727 9 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20728 9 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20729 9 break;
20730
20731 case iFairyMoving:
20732 9 itemsbuf[i].misc1 = moving_fairy_hearts;
20733 9 itemsbuf[i].misc2 = moving_fairy_magic;
20734 9 itemsbuf[i].misc3 = 50;
20735 9 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20736 9 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20737 9 break;
20738
20739 case iRPotion:
20740 9 itemsbuf[i].misc1 = red_potion_hearts;
20741 9 itemsbuf[i].misc2 = red_potion_magic;
20742 9 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20743 9 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20744 9 break;
20745
20746 case iBPotion:
20747 9 itemsbuf[i].misc1 = blue_potion_hearts;
20748 9 itemsbuf[i].misc2 = blue_potion_magic;
20749 9 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20750 9 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20751 9 break;
20752
20753 case iSword:
20754 9 itemsbuf[i].pickup_hearts = sword_hearts[0];
20755 9 itemsbuf[i].misc1 = beam_hearts[0];
20756 9 itemsbuf[i].misc2 = beam_power[0];
20757 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20758
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20759 9 break;
20760
20761 case iWSword:
20762 9 itemsbuf[i].pickup_hearts = sword_hearts[1];
20763 9 itemsbuf[i].misc1 = beam_hearts[1];
20764 9 itemsbuf[i].misc2 = beam_power[1];
20765
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20766 9 break;
20767
20768 case iMSword:
20769 9 itemsbuf[i].pickup_hearts = sword_hearts[2];
20770 9 itemsbuf[i].misc1 = beam_hearts[2];
20771 9 itemsbuf[i].misc2 = beam_power[2];
20772
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20773 9 break;
20774
20775 case iXSword:
20776 9 itemsbuf[i].pickup_hearts = sword_hearts[3];
20777 9 itemsbuf[i].misc1 = beam_hearts[3];
20778 9 itemsbuf[i].misc2 = beam_power[3];
20779
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20780 9 break;
20781
20782 case iHookshot:
20783 9 itemsbuf[i].misc1 = hookshot_length;
20784 9 itemsbuf[i].misc2 = hookshot_links;
20785 9 break;
20786
20787 case iLongshot:
20788 9 itemsbuf[i].misc1 = longshot_length;
20789 9 itemsbuf[i].misc2 = longshot_links;
20790 9 break;
20791 }
20792 2313 }
20793
20794
3/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
109 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20795 {
20796 //was new subscreen rule
20797
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.subscreen=get_bit(quest_rules,qr_FREEFORM)?1:0;
20798
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(quest_rules,qr_FREEFORM,0);
20799 4 }
20800
20801
3/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
109 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20802 {
20803 4 temp_zinit.start_dmap=0;
20804 4 }
20805
20806
3/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
109 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20807 {
20808
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.heroAnimationStyle=get_bit(quest_rules,qr_BSZELDA)?1:0;
20809 4 }
20810
20811
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
109 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20812 {
20813 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20814 temp_zinit.max_rupees=999;
20815 //temp_zinit.rupies=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20816 }
20817
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20818 {
20819 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20820 temp_zinit.max_bombs = 8;
20821 }
20822 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20823 //time to ensure that we port all new values properly:
20824
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 9 times.
109 if(Header->zelda_version < 0x250)
20825 {
20826
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 temp_zinit.max_sbombs = temp_zinit.bomb_ratio > 0 ? ( temp_zinit.max_bombs/temp_zinit.bomb_ratio ) : (temp_zinit.max_bombs/4);
20827 9 }
20828
20829
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(s_version > 21)
20830 {
20831
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_getc(&temp_zinit.hp_per_heart,f,true))
20832 {
20833 return qe_invalid;
20834 }
20835
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_getc(&temp_zinit.magic_per_block,f,true))
20836 {
20837 return qe_invalid;
20838 }
20839
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_getc(&temp_zinit.hero_damage_multiplier,f,true))
20840 {
20841 return qe_invalid;
20842 }
20843
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_getc(&temp_zinit.ene_damage_multiplier,f,true))
20844 {
20845 return qe_invalid;
20846 }
20847 25 }
20848 else
20849 {
20850 84 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20851 84 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20852 84 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20853 84 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20854 }
20855
20856
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(s_version > 22)
20857 {
20858
2/2
✓ Branch 0 taken 625 times.
✓ Branch 1 taken 25 times.
650 for(int32_t q = 0; q < 25; ++q)
20859 {
20860
2/4
✓ Branch 0 taken 625 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 625 times.
625 if(!p_igetw(&temp_zinit.scrcnt[q],f,true))
20861 {
20862 return qe_invalid;
20863 }
20864 625 }
20865
2/2
✓ Branch 0 taken 625 times.
✓ Branch 1 taken 25 times.
650 for(int32_t q = 0; q < 25; ++q)
20866 {
20867
2/4
✓ Branch 0 taken 625 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 625 times.
625 if(!p_igetw(&temp_zinit.scrmaxcnt[q],f,true))
20868 {
20869 return qe_invalid;
20870 }
20871 625 }
20872 25 }
20873 else
20874 {
20875
2/2
✓ Branch 0 taken 2100 times.
✓ Branch 1 taken 84 times.
2184 for(int32_t q = 0; q < 25; ++q)
20876 {
20877 2100 temp_zinit.scrcnt[q] = 0;
20878 2100 temp_zinit.scrmaxcnt[q] = 0;
20879 2100 }
20880 }
20881
20882
20883
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(s_version > 23)
20884 {
20885
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_getc(&temp_zinit.dither_type,f,true))
20886 {
20887 return qe_invalid;
20888 }
20889
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_getc(&temp_zinit.dither_arg,f,true))
20890 {
20891 return qe_invalid;
20892 }
20893
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_getc(&temp_zinit.dither_percent,f,true))
20894 {
20895 return qe_invalid;
20896 }
20897
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_getc(&temp_zinit.def_lightrad,f,true))
20898 {
20899 return qe_invalid;
20900 }
20901
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_getc(&temp_zinit.transdark_percent,f,true))
20902 {
20903 return qe_invalid;
20904 }
20905 25 }
20906 else
20907 {
20908 84 temp_zinit.dither_type = 0;
20909 84 temp_zinit.dither_arg = 0;
20910 84 temp_zinit.dither_percent = 20;
20911 84 temp_zinit.def_lightrad = 24;
20912 84 temp_zinit.transdark_percent = 0;
20913 }
20914
20915
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(s_version > 24)
20916 {
20917
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_getc(&temp_zinit.darkcol,f,true))
20918 {
20919 return qe_invalid;
20920 }
20921 25 }
20922 else
20923 {
20924 84 temp_zinit.darkcol = BLACK;
20925 }
20926
20927
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(s_version > 25)
20928 {
20929
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_igetl(&temp_zinit.gravity2,f,true))
20930 {
20931 return qe_invalid;
20932 }
20933
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_igetl(&temp_zinit.swimgravity,f,true))
20934 {
20935 return qe_invalid;
20936 }
20937 25 }
20938 else
20939 {
20940 84 temp_zinit.gravity2 = temp_zinit.gravity*100;
20941 84 temp_zinit.swimgravity = 5;
20942 }
20943
20944
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(s_version > 26)
20945 {
20946
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f,true))
20947 {
20948 return qe_invalid;
20949 }
20950
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f,true))
20951 {
20952 return qe_invalid;
20953 }
20954
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f,true))
20955 {
20956 return qe_invalid;
20957 }
20958 25 }
20959 else
20960 {
20961 84 temp_zinit.heroSideswimUpStep = 150;
20962 84 temp_zinit.heroSideswimSideStep = 100;
20963 84 temp_zinit.heroSideswimDownStep = 75;
20964 }
20965
20966
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(s_version > 27)
20967 {
20968
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_igetl(&temp_zinit.exitWaterJump,f,true))
20969 {
20970 return qe_invalid;
20971 }
20972 25 }
20973 else
20974 {
20975 84 temp_zinit.exitWaterJump = 0;
20976 }
20977
20978
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(s_version > 29)
20979 {
20980
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_igetl(&temp_zinit.bunny_ltm,f,true))
20981 {
20982 return qe_invalid;
20983 }
20984 25 }
20985 else
20986 {
20987 84 temp_zinit.bunny_ltm = 0;
20988 }
20989
20990
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(s_version > 30)
20991 {
20992
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_getc(&temp_zinit.switchhookstyle,f,true))
20993 {
20994 return qe_invalid;
20995 }
20996 25 }
20997 else
20998 {
20999 84 temp_zinit.switchhookstyle = 1;
21000 }
21001
21002
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 84 times.
109 if(s_version > 31)
21003 {
21004
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
25 if(!p_getc(&temp_zinit.magicdrainrate,f,true))
21005 {
21006 return qe_invalid;
21007 }
21008 25 }
21009 else
21010 {
21011
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 temp_zinit.magicdrainrate = (get_bit(temp_zinit.misc,idM_DOUBLEMAGIC) ? 1 : 2);
21012
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
21013 }
21014
21015
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 temp_zinit.clear_genscript();
21016
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 88 times.
109 if(s_version > 32)
21017 {
21018 21 word numgenscript = 0;
21019
2/4
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
21 if(!p_igetw(&numgenscript,f,true))
21020 return qe_invalid;
21021
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1 times.
22 for(auto q = 1; q < numgenscript; ++q)
21022 {
21023
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_getc(&padding,f,true))
21024 return qe_invalid;
21025
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!(padding&2))
21026 continue;
21027 1 temp_zinit.gen_doscript[q] = padding&1;
21028
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetw(&temp_zinit.gen_exitState[q],f,true))
21029 return qe_invalid;
21030
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_igetw(&temp_zinit.gen_reloadState[q],f,true))
21031 return qe_invalid;
21032
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8 times.
9 for(auto p = 0; p < 8; ++p)
21033
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if(!p_igetl(&temp_zinit.gen_initd[q][p],f,true))
21034 return qe_invalid;
21035
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetl(&temp_zinit.gen_dataSize[q],f,true))
21036 return qe_invalid;
21037
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_getlvec<int32_t>(&temp_zinit.gen_data[q],f,true))
21038 return qe_invalid;
21039
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetl(&temp_zinit.gen_eventstate[q],f,true))
21040 return qe_invalid;
21041 1 }
21042 21 }
21043
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 99 times.
109 if(s_version > 33)
21044 {
21045
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
10 if(!p_getc(&temp_zinit.hero_swim_mult,f,true))
21046 return qe_invalid;
21047
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
10 if(!p_getc(&temp_zinit.hero_swim_div,f,true))
21048 return qe_invalid;
21049 10 }
21050
21051
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if(keepdata==true)
21052 {
21053
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 zinit = temp_zinit;
21054
21055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(zinit.heroAnimationStyle==las_zelda3slow)
21056 {
21057 hero_animation_speed=2;
21058 }
21059 else
21060 {
21061 109 hero_animation_speed=1;
21062 }
21063 109 }
21064
21065 109 return 0;
21066 433 }
21067
21068 /*
21069 void setupitemdropsets()
21070 {
21071 for(int32_t i=0; i<isMAX; i++)
21072 {
21073 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
21074 }
21075 }
21076 */
21077
21078 104 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build, bool keepdata)
21079 {
21080 104 build=build; // here to prevent compiler warnings
21081 dword dummy_dword;
21082 104 word item_drop_sets_to_read=0;
21083 item_drop_object tempitemdrop;
21084 104 word s_version=0, s_cversion=0;
21085
21086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata)
21087 {
21088
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
21089 {
21090 26624 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
21091 26624 }
21092 104 }
21093
21094
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 4 times.
104 if(version > 0x192)
21095 {
21096 100 item_drop_sets_to_read=0;
21097
21098 //section version info
21099
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetw(&s_version,f,true))
21100 {
21101 return qe_invalid;
21102 }
21103
21104 100 FFCore.quest_format[vItemDropsets] = s_version;
21105
21106 //al_trace("Item drop sets version %d\n", s_version);
21107
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetw(&s_cversion,f,true))
21108 {
21109 return qe_invalid;
21110 }
21111
21112 //section size
21113
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&dummy_dword,f,true))
21114 {
21115 return qe_invalid;
21116 }
21117
21118 //finally... section data
21119
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetw(&item_drop_sets_to_read,f,true))
21120 {
21121 return qe_invalid;
21122 }
21123 100 }
21124 else
21125 {
21126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(keepdata==true)
21127 {
21128 4 init_item_drop_sets();
21129 4 }
21130 }
21131
21132
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 100 times.
104 if(s_version>=1)
21133 {
21134
2/2
✓ Branch 0 taken 1899 times.
✓ Branch 1 taken 100 times.
1999 for(int32_t i=0; i<item_drop_sets_to_read; i++)
21135 {
21136
1/2
✓ Branch 0 taken 1899 times.
✗ Branch 1 not taken.
1899 if(!pfread(tempitemdrop.name,sizeof(tempitemdrop.name),f,true))
21137 {
21138 return qe_invalid;
21139 }
21140
21141
2/2
✓ Branch 0 taken 18990 times.
✓ Branch 1 taken 1899 times.
20889 for(int32_t j=0; j<10; ++j)
21142 {
21143
1/2
✓ Branch 0 taken 18990 times.
✗ Branch 1 not taken.
18990 if(!p_igetw(&tempitemdrop.item[j],f,true))
21144 {
21145 return qe_invalid;
21146 }
21147 18990 }
21148
21149
2/2
✓ Branch 0 taken 20889 times.
✓ Branch 1 taken 1899 times.
22788 for(int32_t j=0; j<11; ++j)
21150 {
21151
1/2
✓ Branch 0 taken 20889 times.
✗ Branch 1 not taken.
20889 if(!p_igetw(&tempitemdrop.chance[j],f,true))
21152 {
21153 return qe_invalid;
21154 }
21155 20889 }
21156
21157 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21158 // overrides the quest's set #12.
21159
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1899 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1899 if(s_version<2 && i==12)
21160 continue;
21161
21162 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21163
1/4
✓ Branch 0 taken 1899 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1899 if(s_version<2) for(int32_t j=0; j<10; ++j)
21164 {
21165 int32_t it = tempitemdrop.item[j];
21166
21167 if((itemsbuf[it].family == itype_rupee
21168 && ((itemsbuf[it].amount)&0xFFF) == 10)
21169 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21170 {
21171 tempitemdrop.chance[j+1]=0;
21172 }
21173 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21174 {
21175 tempitemdrop.chance[j+1]=0;
21176 }
21177
21178 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21179 if(itemsbuf[it].family == itype_misc)
21180 {
21181 // If a non-gameplay item was selected, then item drop was aborted.
21182 // Reflect this by increasing the 'Nothing' chance accordingly.
21183 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21184 tempitemdrop.chance[j+1]=0;
21185 }
21186 }
21187
21188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1899 times.
1899 if(keepdata)
21189 {
21190 1899 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21191 1899 }
21192 1899 }
21193 100 }
21194
21195 104 return 0;
21196 104 }
21197
21198 100 int32_t readfavorites(PACKFILE *f, int32_t, word, bool keepdata)
21199 {
21200 int32_t temp_num;
21201 dword dummy_dword;
21202 word num_favorite_combos;
21203 word num_favorite_combo_aliases;
21204 100 word s_version=0, s_cversion=0;
21205
21206 //section version info
21207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_igetw(&s_version,f,true))
21208 {
21209 return qe_invalid;
21210 }
21211
21212 100 FFCore.quest_format[vFavourites] = s_version;
21213
21214
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetw(&s_cversion,f,true))
21215 {
21216 return qe_invalid;
21217 }
21218
21219 //section size
21220
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetl(&dummy_dword,f,true))
21221 {
21222 return qe_invalid;
21223 }
21224
21225 100 word per_row = FAVORITECOMBO_PER_ROW;
21226
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 10 times.
100 if(s_version >= 3)
21227
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(!p_igetw(&per_row,f,true))
21228 return qe_invalid;
21229 //finally... section data
21230
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetw(&num_favorite_combos,f,true))
21231 {
21232 return qe_invalid;
21233 }
21234
21235 //Hack; port old favorite combos
21236
3/4
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 90 times.
100 if(s_version < 3 && num_favorite_combos == 100)
21237 90 per_row = 13;
21238
21239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
21240 {
21241
2/2
✓ Branch 0 taken 30000 times.
✓ Branch 1 taken 100 times.
30100 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21242 30000 favorite_combos[q] = -1;
21243
2/2
✓ Branch 0 taken 30000 times.
✓ Branch 1 taken 100 times.
30100 for(int q = 0; q < MAXFAVORITECOMBOALIASES; ++q)
21244 30000 favorite_comboaliases[q] = -1;
21245 100 }
21246
2/2
✓ Branch 0 taken 9513 times.
✓ Branch 1 taken 100 times.
9613 for(int32_t i=0; i<num_favorite_combos; i++)
21247 {
21248
1/2
✓ Branch 0 taken 9513 times.
✗ Branch 1 not taken.
9513 if(!p_igetl(&temp_num,f,true))
21249 {
21250 return qe_invalid;
21251 }
21252
21253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9513 times.
9513 if(keepdata)
21254 {
21255
2/2
✓ Branch 0 taken 513 times.
✓ Branch 1 taken 9000 times.
9513 if(per_row == FAVORITECOMBO_PER_ROW)
21256 513 favorite_combos[i]=temp_num;
21257 else
21258 {
21259 9000 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21260 9000 favorite_combos[new_i]=temp_num;
21261 }
21262 9513 }
21263 9513 }
21264
21265
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetw(&num_favorite_combo_aliases,f,true))
21266 {
21267 return qe_invalid;
21268 }
21269
21270
2/2
✓ Branch 0 taken 9000 times.
✓ Branch 1 taken 100 times.
9100 for(int32_t i=0; i<num_favorite_combo_aliases; i++)
21271 {
21272
1/2
✓ Branch 0 taken 9000 times.
✗ Branch 1 not taken.
9000 if(!p_igetl(&temp_num,f,true))
21273 {
21274 return qe_invalid;
21275 }
21276
21277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9000 times.
9000 if(keepdata)
21278 {
21279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9000 times.
9000 if(per_row == FAVORITECOMBO_PER_ROW)
21280 favorite_comboaliases[i]=temp_num;
21281 else
21282 {
21283 9000 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21284 9000 favorite_comboaliases[new_i]=temp_num;
21285 }
21286 9000 }
21287 9000 }
21288
21289 100 word max_combo_cols = 0;
21290 100 word max_mappages = 0;
21291
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 10 times.
100 if(s_version >= 2)
21292 {
21293
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(!p_igetw(&max_combo_cols,f,true))
21294 return qe_invalid;
21295 10 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21296
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 10 times.
50 for(int q = 0; q < max_combo_cols; ++q)
21297 {
21298
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_igetl(&tmp,f,true))
21299 return qe_invalid;
21300
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_igetl(&tmp2,f,true))
21301 return qe_invalid;
21302
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_igetl(&tmp3,f,true))
21303 return qe_invalid;
21304
2/4
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
40 if(keepdata && q < MAX_COMBO_COLS)
21305 {
21306 40 First[q] = tmp;
21307 40 combo_alistpos[q] = tmp2;
21308 40 combo_pool_listpos[q] = tmp3;
21309 40 }
21310 40 }
21311
21312
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(!p_igetw(&max_mappages,f,true))
21313 return qe_invalid;
21314
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 10 times.
100 for(int q = 0; q < max_mappages; ++q)
21315 {
21316
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(!p_igetl(&tmp,f,true))
21317 return qe_invalid;
21318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90 times.
90 if(!p_igetl(&tmp2,f,true))
21319 return qe_invalid;
21320
2/4
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 90 times.
90 if(keepdata && q < MAX_MAPPAGE_BTNS)
21321 {
21322 90 map_page[q].map = tmp;
21323 90 map_page[q].screen = tmp2;
21324 90 }
21325 90 }
21326 10 }
21327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(keepdata)
21328 {
21329
2/2
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 100 times.
460 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21330 {
21331 360 First[q] = 0;
21332 360 combo_alistpos[q] = 0;
21333 360 combo_pool_listpos[q] = 0;
21334 360 }
21335
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 100 times.
910 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21336 {
21337 810 map_page[q].map = 0;
21338 810 map_page[q].screen = 0;
21339 810 }
21340 100 }
21341
21342 100 return 0;
21343 100 }
21344
21345 /*
21346 switch (ret) {
21347 case 0:
21348 break;
21349
21350 case qe_invalid:
21351 goto invalid;
21352 break;
21353 default:
21354 pack_fclose(f);
21355 if(!oldquest)
21356 delete_file(tmpfilename);
21357 return ret;
21358 break;
21359 }
21360 */
21361
21362 const char *skip_text[skip_max]=
21363 {
21364 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21365 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21366 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21367 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21368 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21369 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21370 "skip_favorites"
21371 };
21372
21373
21374 void port250QuestRules(){
21375
21376 portCandleRules(); //Candle
21377 portBombRules();
21378
21379 }
21380
21381 void portCandleRules()
21382 {
21383 bool hurtshero = get_bit(quest_rules,qr_FIREPROOFHERO);
21384 //itemdata itemsbuf;
21385 for ( int32_t q = 0; q < MAXITEMS; q++ )
21386 {
21387 if ( itemsbuf[q].family == itype_candle )
21388 {
21389 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21390 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21391 }
21392 }
21393 }
21394
21395 void portBombRules()
21396 {
21397 bool hurtshero = get_bit(quest_rules,qr_OUCHBOMBS);
21398 //itemdata itemsbuf;
21399 for ( int32_t q = 0; q < MAXITEMS; q++ )
21400 {
21401 if ( itemsbuf[q].family == itype_bomb )
21402 {
21403 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21404 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21405 }
21406 }
21407
21408 }
21409
21410 //Internal function for loadquest wrapper
21411 109 int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool keepall, const byte *skip_flags, byte printmetadata)
21412 {
21413 109 DMapEditorLastMaptileUsed = 0;
21414 109 combosread=false;
21415 109 mapsread=false;
21416 109 fixffcs=false;
21417
21418
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
109 if(get_debug()&&(key[KEY_LSHIFT]||key[KEY_RSHIFT]))
21419 {
21420 keepall=false;
21421 jwin_alert("Load Quest","Data retention disabled.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
21422 }
21423
21424 // show_progress=true;
21425 char tmpfilename[L_tmpnam];
21426 109 temp_name(tmpfilename);
21427 // char percent_done[30];
21428 109 bool catchup=false;
21429 byte tempbyte;
21430 109 word old_map_count=map_count;
21431
21432 109 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21433 109 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21434 109 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21435
21436
2/4
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 109 times.
109 if(keepall==false||get_bit(skip_flags, skip_rules))
21437 {
21438 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21439 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21440 }
21441
21442 109 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21443 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21444
21445
2/4
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 109 times.
109 if(keepall==false||get_bit(skip_flags, skip_midis))
21446 {
21447 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21448 }
21449
21450
21451
2/4
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 109 times.
109 if(keepall&&!get_bit(skip_flags, skip_ffscript))
21452 {
21453 109 zScript.clear();
21454 109 globalmap.clear();
21455 109 genericmap.clear();
21456 109 ffcmap.clear();
21457 109 itemmap.clear();
21458 109 npcmap.clear();
21459 109 ewpnmap.clear();
21460 109 lwpnmap.clear();
21461 109 playermap.clear();
21462 109 dmapmap.clear();
21463 109 screenmap.clear();
21464 109 itemspritemap.clear();
21465 109 comboscriptmap.clear();
21466
21467
2/2
✓ Branch 0 taken 55699 times.
✓ Branch 1 taken 109 times.
55808 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21468 {
21469 55699 ffcmap[i].clear();
21470 55699 }
21471
21472 109 globalmap[0].slotname = "Slot 1:";
21473 109 globalmap[0].scriptname = "~Init";
21474 109 globalmap[0].update();
21475
21476
2/2
✓ Branch 0 taken 763 times.
✓ Branch 1 taken 109 times.
872 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21477 {
21478 763 globalmap[i].clear();
21479 763 }
21480
21481
2/2
✓ Branch 0 taken 27795 times.
✓ Branch 1 taken 109 times.
27904 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21482 {
21483 27795 itemmap[i].clear();
21484 27795 }
21485
21486 //new script types -- prevent carrying over to a quest that you load after reading them
21487 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21488
2/2
✓ Branch 0 taken 27795 times.
✓ Branch 1 taken 109 times.
27904 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21489 {
21490 27795 npcmap[i].clear();
21491 27795 }
21492
2/2
✓ Branch 0 taken 27795 times.
✓ Branch 1 taken 109 times.
27904 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21493 {
21494 27795 lwpnmap[i].clear();
21495 27795 }
21496
2/2
✓ Branch 0 taken 27795 times.
✓ Branch 1 taken 109 times.
27904 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21497 {
21498 27795 ewpnmap[i].clear();
21499 27795 }
21500
2/2
✓ Branch 0 taken 436 times.
✓ Branch 1 taken 109 times.
545 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21501 {
21502 436 playermap[i].clear();
21503 436 }
21504
2/2
✓ Branch 0 taken 27795 times.
✓ Branch 1 taken 109 times.
27904 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21505 {
21506 27795 dmapmap[i].clear();
21507 27795 }
21508
2/2
✓ Branch 0 taken 27795 times.
✓ Branch 1 taken 109 times.
27904 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21509 {
21510 27795 screenmap[i].clear();
21511 27795 }
21512
2/2
✓ Branch 0 taken 27795 times.
✓ Branch 1 taken 109 times.
27904 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21513 {
21514 27795 itemspritemap[i].clear();
21515 27795 }
21516
2/2
✓ Branch 0 taken 55699 times.
✓ Branch 1 taken 109 times.
55808 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21517 {
21518 55699 comboscriptmap[i].clear();
21519 55699 }
21520
2/2
✓ Branch 0 taken 55699 times.
✓ Branch 1 taken 109 times.
55808 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21521 {
21522 55699 genericmap[i].clear();
21523 55699 }
21524
21525 109 reset_scripts();
21526 109 }
21527
21528 zquestheader tempheader;
21529 109 memset(&tempheader, 0, sizeof(zquestheader));
21530 109 zinfo tempzi;
21531 109 tempzi.clear();
21532 109 load_tmp_zi = &tempzi;
21533
21534 // oldquest flag is set when an unencrypted qst file is suspected.
21535 109 bool oldquest = false;
21536 109 int32_t open_error=0;
21537 109 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21538
21539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if (!f)
21540 {
21541 ASSERT(open_error != 0);
21542 return open_error;
21543 }
21544 char zinfofilename[2048];
21545 109 replace_extension(zinfofilename, filename, "zinfo", 2047);
21546 109 int32_t ret=0;
21547
21548 //header
21549 109 box_out("Reading Header...");
21550 109 ret=readheader(f, &tempheader, true, printmetadata);
21551
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 109 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
109 checkstatus(ret);
21552 109 box_out("okay.");
21553 109 box_eol();
21554
21555
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 25 times.
109 if(read_zinfo)
21556 {
21557 25 box_out("Reading ZInfo - ");
21558
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 box_out(read_ext_zinfo ? "External..." : "Internal...");
21559
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 if(read_ext_zinfo)
21560 {
21561 1 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21562 1 ret=readzinfo(inf, tempzi, tempheader);
21563
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(inf) pack_fclose(inf);
21564
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 checkstatus(ret);
21565 1 }
21566 else
21567 {
21568 24 ret=readzinfo(f, tempzi, tempheader);
21569
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
24 checkstatus(ret);
21570 }
21571 25 box_out("okay.");
21572 25 box_eol();
21573 25 }
21574
21575
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
109 if(tempheader.zelda_version>=0x193)
21576 {
21577 dword section_id;
21578
21579 //section id
21580
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(!p_mgetl(&section_id,f,true))
21581 {
21582 return qe_invalid;
21583 }
21584
21585
2/2
✓ Branch 0 taken 2475 times.
✓ Branch 1 taken 105 times.
2580 while(!pack_feof(f))
21586 {
21587
24/25
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 105 times.
✓ Branch 3 taken 105 times.
✓ Branch 4 taken 105 times.
✓ Branch 5 taken 105 times.
✓ Branch 6 taken 100 times.
✓ Branch 7 taken 105 times.
✓ Branch 8 taken 105 times.
✓ Branch 9 taken 105 times.
✓ Branch 10 taken 105 times.
✓ Branch 11 taken 105 times.
✓ Branch 12 taken 105 times.
✓ Branch 13 taken 100 times.
✓ Branch 14 taken 100 times.
✓ Branch 15 taken 105 times.
✓ Branch 16 taken 105 times.
✓ Branch 17 taken 100 times.
✓ Branch 18 taken 100 times.
✓ Branch 19 taken 100 times.
✓ Branch 20 taken 100 times.
✓ Branch 21 taken 105 times.
✓ Branch 22 taken 105 times.
✓ Branch 23 taken 100 times.
✓ Branch 24 taken 100 times.
2475 switch(section_id)
21588 {
21589 case ID_RULES:
21590
21591 //rules
21592
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21593 {
21594 box_out("found.");
21595 box_eol();
21596 catchup=false;
21597 }
21598
21599 105 box_out("Reading Rules...");
21600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
21601
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21602 105 box_out("okay.");
21603 105 box_eol();
21604 105 break;
21605
21606 case ID_STRINGS:
21607
21608 //strings
21609
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21610 {
21611 box_out("found.");
21612 box_eol();
21613 catchup=false;
21614 }
21615
21616 105 box_out("Reading Strings...");
21617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
21618
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21619 105 box_out("okay.");
21620 105 box_eol();
21621 105 break;
21622
21623 case ID_MISC:
21624
21625 //misc data
21626
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21627 {
21628 box_out("found.");
21629 box_eol();
21630 catchup=false;
21631 }
21632
21633 105 box_out("Reading Misc. Data...");
21634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
21635
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21636 105 box_out("okay.");
21637 105 box_eol();
21638 105 break;
21639
21640 case ID_TILES:
21641
21642 //tiles
21643
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21644 {
21645 box_out("found.");
21646 box_eol();
21647 catchup=false;
21648 }
21649
21650 105 box_out("Reading Tiles...");
21651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
21652
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21653 105 box_out("okay.");
21654 105 box_eol();
21655 105 break;
21656
21657 case ID_COMBOS:
21658
21659 //combos
21660
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21661 {
21662 box_out("found.");
21663 box_eol();
21664 catchup=false;
21665 }
21666
21667 105 box_out("Reading Combos...");
21668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
21669 105 combosread=true;
21670
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21671 105 box_out("okay.");
21672 105 box_eol();
21673 105 break;
21674
21675 case ID_COMBOALIASES:
21676
21677 //combo aliases
21678
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(catchup)
21679 {
21680 box_out("found.");
21681 box_eol();
21682 catchup=false;
21683 }
21684
21685 100 box_out("Reading Combo Aliases...");
21686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_comboaliases));
21687
1/5
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
100 checkstatus(ret);
21688 100 box_out("okay.");
21689 100 box_eol();
21690 100 break;
21691
21692 case ID_CSETS:
21693
21694 //color data
21695
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21696 {
21697 box_out("found.");
21698 box_eol();
21699 catchup=false;
21700 }
21701
21702 105 box_out("Reading Color Data...");
21703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
21704
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21705 105 box_out("okay.");
21706 105 box_eol();
21707 105 break;
21708
21709 case ID_MAPS:
21710
21711 //maps
21712
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21713 {
21714 box_out("found.");
21715 box_eol();
21716 catchup=false;
21717 }
21718
21719 105 box_out("Reading Maps...");
21720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
21721 105 mapsread=true;
21722
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21723 105 box_out("okay.");
21724 105 box_eol();
21725 105 break;
21726
21727 case ID_DMAPS:
21728
21729 //dmaps
21730
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21731 {
21732 box_out("found.");
21733 box_eol();
21734 catchup=false;
21735 }
21736
21737 105 box_out("Reading DMaps...");
21738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
21739
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21740 105 box_out("okay.");
21741 105 box_eol();
21742 105 break;
21743
21744 case ID_DOORS:
21745
21746 //door combo sets
21747
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21748 {
21749 box_out("found.");
21750 box_eol();
21751 catchup=false;
21752 }
21753
21754 105 box_out("Reading Doors...");
21755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
21756
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21757 105 box_out("okay.");
21758 105 box_eol();
21759 105 break;
21760
21761 case ID_ITEMS:
21762
21763 //items
21764
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21765 {
21766 box_out("found.");
21767 box_eol();
21768 catchup=false;
21769 }
21770
21771 105 box_out("Reading Items...");
21772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
21773
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21774
21775 105 box_out("okay.");
21776 105 box_eol();
21777 105 break;
21778
21779 case ID_WEAPONS:
21780
21781 //weapons
21782
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21783 {
21784 box_out("found.");
21785 box_eol();
21786 catchup=false;
21787 }
21788
21789 105 box_out("Reading Weapons...");
21790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
21791
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21792 105 box_out("okay.");
21793 105 box_eol();
21794 105 break;
21795
21796 case ID_COLORS:
21797
21798 //misc. colors
21799
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(catchup)
21800 {
21801 box_out("found.");
21802 box_eol();
21803 catchup=false;
21804 }
21805
21806 100 box_out("Reading Misc. Colors...");
21807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 ret=readmisccolors(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_colors));
21808
1/5
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
100 checkstatus(ret);
21809 100 box_out("okay.");
21810 100 box_eol();
21811 100 break;
21812
21813 case ID_ICONS:
21814
21815 //game icons
21816
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(catchup)
21817 {
21818 box_out("found.");
21819 box_eol();
21820 catchup=false;
21821 }
21822
21823 100 box_out("Reading Game Icons...");
21824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 ret=readgameicons(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_icons));
21825
1/5
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
100 checkstatus(ret);
21826 100 box_out("okay.");
21827 100 box_eol();
21828 100 break;
21829
21830 case ID_INITDATA:
21831
21832 //initialization data
21833
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21834 {
21835 box_out("found.");
21836 box_eol();
21837 catchup=false;
21838 }
21839
21840 105 box_out("Reading Init. Data...");
21841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
21842
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21843 105 box_out("okay.");
21844 105 box_eol();
21845
21846
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
105 if(keepall&&!get_bit(skip_flags, skip_subscreens))
21847 {
21848
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 19 times.
105 if(zinit.subscreen!=ssdtMAX) //not using custom subscreens
21849 {
21850 19 setupsubscreens();
21851
21852
2/2
✓ Branch 0 taken 9728 times.
✓ Branch 1 taken 19 times.
9747 for(int32_t i=0; i<MAXDMAPS; ++i)
21853 {
21854 9728 int32_t type=DMaps[i].type&dmfTYPE;
21855
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 9634 times.
9728 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21856 9728 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
21857 9728 }
21858 19 }
21859 105 }
21860
21861
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
105 if(keepall&&!get_bit(skip_flags, skip_sfx))
21862 {
21863 105 setupsfx();
21864 105 }
21865
21866
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
105 if(keepall&&!get_bit(skip_flags, skip_itemdropsets))
21867 {
21868 105 init_item_drop_sets();
21869 105 }
21870
21871
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
105 if(keepall&&!get_bit(skip_flags, skip_favorites))
21872 {
21873 105 init_favorites();
21874 105 }
21875
21876 105 break;
21877
21878 case ID_GUYS:
21879
21880 //guys
21881
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21882 {
21883 box_out("found.");
21884 box_eol();
21885 catchup=false;
21886 }
21887
21888 105 box_out("Reading Custom Guy Data...");
21889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
21890
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21891 105 box_out("okay.");
21892 105 box_eol();
21893 105 break;
21894
21895 case ID_HEROSPRITES:
21896
21897 //player sprites
21898
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(catchup)
21899 {
21900 box_out("found.");
21901 box_eol();
21902 catchup=false;
21903 }
21904
21905 100 box_out("Reading Custom Player Sprite Data...");
21906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 ret=readherosprites(f, &tempheader, keepall&&!get_bit(skip_flags, skip_herosprites));
21907
1/5
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
100 checkstatus(ret);
21908 100 box_out("okay.");
21909 100 box_eol();
21910 100 break;
21911
21912 case ID_SUBSCREEN:
21913
21914 //custom subscreens
21915
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(catchup)
21916 {
21917 box_out("found.");
21918 box_eol();
21919 catchup=false;
21920 }
21921
21922 100 box_out("Reading Custom Subscreen Data...");
21923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 ret=readsubscreens(f, &tempheader, keepall&&!get_bit(skip_flags, skip_subscreens));
21924
1/5
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
100 checkstatus(ret);
21925 100 box_out("okay.");
21926 100 box_eol();
21927 100 break;
21928
21929 case ID_FFSCRIPT:
21930
21931 //Freeform combo scripts
21932
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(catchup)
21933 {
21934 box_out("found.");
21935 box_eol();
21936 catchup=false;
21937 }
21938
21939 100 box_out("Reading FF Script Data...");
21940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 ret=readffscript(f, &tempheader, keepall&&!get_bit(skip_flags, skip_ffscript));
21941
1/5
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
100 checkstatus(ret);
21942 100 box_out("okay.");
21943 100 box_eol();
21944 100 break;
21945
21946 case ID_SFX:
21947
21948 //SFX data
21949
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(catchup)
21950 {
21951 box_out("found.");
21952 box_eol();
21953 catchup=false;
21954 }
21955
21956 100 box_out("Reading SFX Data...");
21957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 ret=readsfx(f, &tempheader, keepall&&!get_bit(skip_flags, skip_sfx));
21958
1/5
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
100 checkstatus(ret);
21959 100 box_out("okay.");
21960 100 box_eol();
21961 100 break;
21962
21963 case ID_MIDIS:
21964
21965 //midis
21966
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21967 {
21968 box_out("found.");
21969 box_eol();
21970 catchup=false;
21971 }
21972
21973 105 box_out("Reading Tunes...");
21974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
21975
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21976 105 box_out("okay.");
21977 105 box_eol();
21978 105 break;
21979
21980 case ID_CHEATS:
21981
21982 //cheat codes
21983
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(catchup)
21984 {
21985 box_out("found.");
21986 box_eol();
21987 catchup=false;
21988 }
21989
21990 105 box_out("Reading Cheat Codes...");
21991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
21992
1/5
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
105 checkstatus(ret);
21993 105 box_out("okay.");
21994 105 box_eol();
21995 105 break;
21996
21997 case ID_ITEMDROPSETS:
21998
21999 //item drop sets
22000
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(catchup)
22001 {
22002 box_out("found.");
22003 box_eol();
22004 catchup=false;
22005 }
22006
22007 100 box_out("Reading Item Drop Sets...");
22008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_itemdropsets));
22009
1/5
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
100 checkstatus(ret);
22010 100 box_out("okay.");
22011 100 box_eol();
22012 100 break;
22013
22014 case ID_FAVORITES:
22015
22016 //favorite combos and combo aliases
22017
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(catchup)
22018 {
22019 box_out("found.");
22020 box_eol();
22021 catchup=false;
22022 }
22023
22024 100 box_out("Reading Favorite Combos...");
22025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 ret=readfavorites(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_favorites));
22026
1/5
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
100 checkstatus(ret);
22027 100 box_out("okay.");
22028 100 box_eol();
22029 100 break;
22030
22031 default:
22032 if(!catchup)
22033 {
22034 box_out("Bad token! Searching...");
22035 box_eol();
22036 }
22037
22038 catchup=true;
22039 break;
22040 }
22041
22042
22043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2475 times.
2475 if(catchup)
22044 {
22045 //section id
22046 section_id=(section_id<<8);
22047
22048 if(!p_getc(&tempbyte,f,true))
22049 {
22050 return qe_invalid;
22051 }
22052
22053 section_id+=tempbyte;
22054 }
22055
22056 else
22057 {
22058 //section id
22059
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 2370 times.
2475 if(!pack_feof(f))
22060 {
22061
1/2
✓ Branch 0 taken 2370 times.
✗ Branch 1 not taken.
2370 if(!p_mgetl(&section_id,f,true))
22062 {
22063 return qe_invalid;
22064 }
22065 2370 }
22066 }
22067 }
22068 105 }
22069 else
22070 {
22071 //rules
22072 4 box_out("Reading Rules...");
22073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
22074
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22075 4 box_out("okay.");
22076 4 box_eol();
22077
22078 //strings
22079 4 box_out("Reading Strings...");
22080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
22081
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22082 4 box_out("okay.");
22083 4 box_eol();
22084
22085 //door combo sets
22086 4 box_out("Reading Doors...");
22087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
22088
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22089 4 box_out("okay.");
22090 4 box_eol();
22091
22092 //dmaps
22093 4 box_out("Reading DMaps...");
22094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
22095
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22096 4 box_out("okay.");
22097 4 box_eol();
22098
22099 // misc data
22100 4 box_out("Reading Misc. Data...");
22101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
22102
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22103 4 box_out("okay.");
22104 4 box_eol();
22105
22106 //items
22107 4 box_out("Reading Items...");
22108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
22109
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22110 4 box_out("okay.");
22111 4 box_eol();
22112
22113 //weapons
22114 4 box_out("Reading Weapons...");
22115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
22116
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22117 4 box_out("okay.");
22118 4 box_eol();
22119
22120 //guys
22121 4 box_out("Reading Custom Guy Data...");
22122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
22123
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22124 4 box_out("okay.");
22125 4 box_eol();
22126
22127 //maps
22128 4 box_out("Reading Maps...");
22129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
22130 4 mapsread=true;
22131
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22132 4 box_out("okay.");
22133 4 box_eol();
22134
22135 //combos
22136 4 box_out("Reading Combos...");
22137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
22138 4 combosread=true;
22139
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22140 4 box_out("okay.");
22141 4 box_eol();
22142
22143 //color data
22144 4 box_out("Reading Color Data...");
22145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
22146
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22147 4 box_out("okay.");
22148 4 box_eol();
22149
22150 //tiles
22151 4 box_out("Reading Tiles...");
22152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
22153
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22154 4 box_out("okay.");
22155 4 box_eol();
22156
22157 //midis
22158 4 box_out("Reading Tunes...");
22159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
22160
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22161 4 box_out("okay.");
22162 4 box_eol();
22163
22164 //cheat codes
22165 4 box_out("Reading Cheat Codes...");
22166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
22167
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22168 4 box_out("okay.");
22169 4 box_eol();
22170
22171 //initialization data
22172 4 box_out("Reading Init. Data...");
22173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
22174
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22175 4 box_out("okay.");
22176 4 box_eol();
22177
22178
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(keepall&&!get_bit(skip_flags, skip_subscreens))
22179 {
22180 4 setupsubscreens();
22181
22182
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t i=0; i<MAXDMAPS; ++i)
22183 {
22184 2048 int32_t type=DMaps[i].type&dmfTYPE;
22185
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2036 times.
2048 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22186 2048 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
22187 2048 }
22188 4 }
22189
22190 4 box_out("Setting Up Default Sound Effects...");
22191
22192
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(keepall&&!get_bit(skip_flags, skip_sfx))
22193 4 setupsfx();
22194
22195 4 box_out("okay.");
22196 4 box_eol();
22197
22198 //player sprites
22199 4 box_out("Reading Custom Player Sprite Data...");
22200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ret=readherosprites2(f, -1, 0, keepall&&!get_bit(skip_flags, skip_herosprites));
22201
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4 checkstatus(ret);
22202 4 box_out("okay.");
22203 4 box_eol();
22204
22205 4 box_out("Setting Up Default Item Drop Sets...");
22206
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 ret=readitemdropsets(f, -1, 0, keepall&&!get_bit(skip_flags, skip_itemdropsets));
22207 4 box_out("okay.");
22208 4 box_eol();
22209 }
22210
22211 109 init_spritelists();
22212
22213 // check data
22214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(f)
22215 {
22216 109 pack_fclose(f);
22217 109 }
22218 109 clear_quest_tmpfile();
22219
22220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(!oldquest)
22221 {
22222
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if(exists(tmpfilename))
22223 {
22224 delete_file(tmpfilename);
22225 }
22226 109 }
22227
22228
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
109 if(fixffcs && combosread && mapsread)
22229 {
22230 for(int32_t i=0; i<map_count; i++)
22231 {
22232 for(int32_t j=0; j<MAPSCRS; j++)
22233 {
22234 for(int32_t m=0; m<32; m++)
22235 {
22236 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].getData()].type == cCHANGE)
22237 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
22238 }
22239 }
22240 }
22241 }
22242
22243
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 22 times.
109 if(get_bit(quest_rules, qr_CONTFULL_DEP))
22244 {
22245 22 set_bit(quest_rules, qr_CONTFULL_DEP, 0);
22246 22 set_bit(zinit.misc, idM_CONTPERCENT, 1);
22247 22 zinit.cont_heart=100;
22248 22 zinit.start_heart=zinit.hc;
22249 22 }
22250
22251 109 box_out("Done.");
22252 109 box_eol();
22253 109 box_end(false);
22254
22255 // if (keepall==true||!get_bit(skip_flags, skip_header))
22256
2/4
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 109 times.
109 if(keepall&&!get_bit(skip_flags, skip_header))
22257 {
22258 109 memcpy(Header, &tempheader, sizeof(tempheader));
22259 109 }
22260
2/4
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 109 times.
109 if(keepall&&!get_bit(skip_flags, skip_zinfo))
22261 {
22262 109 ZI.copyFrom(tempzi);
22263 109 }
22264
22265
2/4
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 109 times.
109 if(!keepall||get_bit(skip_flags, skip_maps))
22266 {
22267 map_count=old_map_count;
22268 }
22269
22270
2/4
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 109 times.
109 if(!keepall||get_bit(skip_flags, skip_rules))
22271 {
22272 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22273 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22274 }
22275
22276
2/4
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 109 times.
109 if(!keepall||get_bit(skip_flags, skip_midis))
22277 {
22278 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22279 }
22280
22281 //Debug FFCore.quest_format[]
22282 109 al_trace("Quest made in ZC Version: %x\n", FFCore.quest_format[vZelda]);
22283 109 al_trace("Quest made in ZC Build: %d\n", FFCore.quest_format[vBuild]);
22284 109 al_trace("Quest Section 'Header' is Version: %d\n", FFCore.quest_format[vHeader]);
22285 109 al_trace("Quest Section 'Rules' is Version: %d\n", FFCore.quest_format[vRules]);
22286 109 al_trace("Quest Section 'Strings' is Version: %d\n", FFCore.quest_format[vStrings]);
22287 109 al_trace("Quest Section 'Misc' is Version: %d\n", FFCore.quest_format[vMisc]);
22288 109 al_trace("Quest Section 'Tiles' is Version: %d\n", FFCore.quest_format[vTiles]);
22289 109 al_trace("Quest Section 'Combos' is Version: %d\n", FFCore.quest_format[vCombos]);
22290 109 al_trace("Quest Section 'CSets' is Version: %d\n", FFCore.quest_format[vCSets]);
22291 109 al_trace("Quest Section 'Maps' is Version: %d\n", FFCore.quest_format[vMaps]);
22292 109 al_trace("Quest Section 'DMaps' is Version: %d\n", FFCore.quest_format[vDMaps]);
22293 109 al_trace("Quest Section 'Doors' is Version: %d\n", FFCore.quest_format[vDoors]);
22294 109 al_trace("Quest Section 'Items' is Version: %d\n", FFCore.quest_format[vItems]);
22295 109 al_trace("Quest Section 'Weapons' is Version: %d\n", FFCore.quest_format[vWeaponSprites]);
22296 109 al_trace("Quest Section 'Colors' is Version: %d\n", FFCore.quest_format[vColours]);
22297 109 al_trace("Quest Section 'Icons' is Version: %d\n", FFCore.quest_format[vIcons]);
22298 //al_trace("Quest Section 'Gfx Pack' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vGfxPack]);
22299 109 al_trace("Quest Section 'InitData' is Version: %d\n", FFCore.quest_format[vInitData]);
22300 109 al_trace("Quest Section 'Guys' is Version: %d\n", FFCore.quest_format[vGuys]);
22301 109 al_trace("Quest Section 'MIDIs' is Version: %d\n", FFCore.quest_format[vMIDIs]);
22302 109 al_trace("Quest Section 'Cheats' is Version: %d\n", FFCore.quest_format[vCheats]);
22303 //al_trace("Quest Section 'Save Format' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vSaveformat]);
22304 109 al_trace("Quest Section 'Combo Aliases' is Version: %d\n", FFCore.quest_format[vComboAliases]);
22305 109 al_trace("Quest Section 'Player Sprites' is Version: %d\n", FFCore.quest_format[vHeroSprites]);
22306 109 al_trace("Quest Section 'Subscreen' is Version: %d\n", FFCore.quest_format[vSubscreen]);
22307 109 al_trace("Quest Section 'Dropsets' is Version: %d\n", FFCore.quest_format[vItemDropsets]);
22308 109 al_trace("Quest Section 'FFScript' is Version: %d\n", FFCore.quest_format[vFFScript]);
22309 109 al_trace("Quest Section 'SFX' is Version: %d\n", FFCore.quest_format[vSFX]);
22310 109 al_trace("Quest Section 'Favorites' is Version: %d\n", FFCore.quest_format[vFavourites]);
22311 109 al_trace("Quest Section 'CompatRules' is Version: %d\n", FFCore.quest_format[vCompatRule]);
22312 //Print metadata for versions under 2.10 here. Bleah.
22313
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
109 if( FFCore.quest_format[vZelda] < 0x210 )
22314 {
22315 4 zprint2("\n[ZQUEST CREATOR METADATA]\n");
22316
22317
1/13
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
4 switch(FFCore.quest_format[vZelda])
22318 {
22319 case 0x193:
22320 {
22321 zprint2("Last saved in ZC Editor Version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22322 }
22323 case 0x192:
22324 {
22325 zprint2("Last saved in ZC Editor Version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22326 }
22327 case 0x190:
22328 {
22329 4 zprint2("Last saved in ZC Editor Version: 1.90");
22330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22331 4 else zprint2("\n");
22332 4 break;
22333 }
22334 case 0x188:
22335 {
22336 zprint2("Last saved in ZC Editor Version: 1.88");
22337 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22338 else zprint2("\n");
22339 break;
22340 }
22341 case 0x187:
22342 {
22343 zprint2("Last saved in ZC Editor Version: 1.87");
22344 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22345 else zprint2("\n");
22346 break;
22347 }
22348 case 0x186:
22349 {
22350 zprint2("Last saved in ZC Editor Version: 1.86");
22351 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22352 else zprint2("\n");
22353 break;
22354 }
22355 case 0x185:
22356 {
22357 zprint2("Last saved in ZC Editor Version: 1.85");
22358 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22359 else zprint2("\n");
22360 break;
22361 }
22362 case 0x184:
22363 {
22364 zprint2("Last saved in ZC Editor Version: 1.84");
22365 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22366 else zprint2("\n");
22367 break;
22368 }
22369 case 0x183:
22370 {
22371 zprint2("Last saved in ZC Editor Version: 1.83");
22372 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22373 else zprint2("\n");
22374 break;
22375 }
22376 case 0x182:
22377 {
22378 zprint2("Last saved in ZC Editor Version: 1.82");
22379 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22380 else zprint2("\n");
22381 break;
22382 }
22383 case 0x181:
22384 {
22385 zprint2("Last saved in ZC Editor Version: 1.81");
22386 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22387 else zprint2("\n");
22388 break;
22389 }
22390 case 0x180:
22391 {
22392 zprint2("Last saved in ZC Editor Version: 1.80");
22393 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22394 else zprint2("\n");
22395 break;
22396 }
22397 default:
22398 {
22399 zprint2("Last saved in ZC Editor Version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22400 }
22401 }
22402 4 }
22403
22404 109 return qe_OK;
22405
22406 invalid:
22407 box_out("error.");
22408 box_eol();
22409 box_end(true);
22410
22411 if(f)
22412 {
22413 pack_fclose(f);
22414 }
22415
22416 if(!oldquest)
22417 {
22418 if(exists(tmpfilename))
22419 {
22420 delete_file(tmpfilename);
22421 }
22422 }
22423
22424 return qe_invalid;
22425
22426 109 }
22427
22428 109 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool keepall, byte *skip_flags, byte printmetadata, bool report, byte qst_num)
22429 {
22430 109 loading_qst_name = filename;
22431 109 loading_qst_num = qst_num;
22432 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22433 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22434
1/2
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
109 if (!is_ci())
22435 loadquest_report = report;
22436 109 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, keepall, skip_flags,printmetadata);
22437 109 load_tmp_zi = NULL;
22438 109 loading_qst_name = NULL;
22439 109 loadquest_report = false;
22440 109 loading_qst_num = 0;
22441 109 return ret;
22442 }
22443